English | Site Directory

Android - An Open Handset Alliance Project

android.util
public class

android.util.DateUtils

java.lang.Object
android.util.DateUtils

Summary

Constants

      Value  
long  DAY_IN_MILLIS    86400000  0x0000000005265c00 
long  HOUR_IN_MILLIS    3600000  0x000000000036ee80 
long  MINUTE_IN_MILLIS    60000  0x000000000000ea60 
long  SECOND_IN_MILLIS    1000  0x00000000000003e8 
long  WEEK_IN_MILLIS    604800000  0x00000000240c8400 
long  YEAR_IN_MILLIS    31449600000  0x00000007528ad000 

Public Constructors

          DateUtils()

Public Methods

    final  static  CharSequence  dateString(long startTime)
      static  String  formatElapsedTime(long elapsedSeconds)
Formats an elapsed time like MM:SS or H:MM:SS for display on the call-in-progress screen.
    final  static  CharSequence  formatSameDayTime(long then, long now, int dateStyle, int timeStyle)
      static  String  getAMPMStr(int ampm, boolean abbrev)
      static  String  getDayOfWeekStr(int dayOfWeek)
      static  String  getDayOfWeekStr(int dayOfWeek, boolean abbrev)
    final  static  int  getFirstDayOfWeek()
This method returns the value for the first day of the week.
      static  String  getMonthStr(int month)
      static  String  getMonthStr(int month, boolean abbrev)
      static  CharSequence  getRelativeTimeSpanString(long time, long now, long minResolution)
Returns a string describing 'time' as a time relative to 'now'.
      static  CharSequence  getRelativeTimeSpanString(long startTime)
      static  CharSequence  getRelativeTimeSpanString(long time, long now, long minResolution, String prefix, String postfix)
    final  static  CharSequence  timeString(Calendar c)
    final  static  CharSequence  timeString(long millis)
Methods inherited from class java.lang.Object

Details

Constants

public static final long DAY_IN_MILLIS

Constant Value: 86400000 (0x0000000005265c00)

public static final long HOUR_IN_MILLIS

Constant Value: 3600000 (0x000000000036ee80)

public static final long MINUTE_IN_MILLIS

Constant Value: 60000 (0x000000000000ea60)

public static final long SECOND_IN_MILLIS

Constant Value: 1000 (0x00000000000003e8)

public static final long WEEK_IN_MILLIS

Constant Value: 604800000 (0x00000000240c8400)

public static final long YEAR_IN_MILLIS

Constant Value: 31449600000 (0x00000007528ad000)

Public Constructors

public DateUtils()

Public Methods

public static final CharSequence dateString(long startTime)

public static String formatElapsedTime(long elapsedSeconds)

Formats an elapsed time like MM:SS or H:MM:SS for display on the call-in-progress screen. TODO: This probably belongs in android.util.DateUtils (alongside functions like getRelativeTimeSpanString().)

public static final CharSequence formatSameDayTime(long then, long now, int dateStyle, int timeStyle)

public static String getAMPMStr(int ampm, boolean abbrev)

public static String getDayOfWeekStr(int dayOfWeek)

public static String getDayOfWeekStr(int dayOfWeek, boolean abbrev)

public static final int getFirstDayOfWeek()

This method returns the value for the first day of the week. This corresponds to the values in java.util.Calendar.

Returns

  • The first day of the week. SUNDAY = 1, MONDAY = 2.

public static String getMonthStr(int month)

public static String getMonthStr(int month, boolean abbrev)

public static CharSequence getRelativeTimeSpanString(long time, long now, long minResolution)

Returns a string describing 'time' as a time relative to 'now'. Time spans in the past are formatted like "42 minutes ago". Time spans in the future are formatted like "in 42 minutes".

Parameters

time the time to describe, in milliseconds
now the current time in milliseconds
minResolution the minimum timespan to report. For example, a time 3 seconds in the past will be reported as "0 minutes ago" if this is set to MINUTE_IN_MILLIS. Pass one of 0, MINUTE_IN_MILLIS, HOUR_IN_MILLIS, DAY_IN_MILLIS, WEEK_IN_MILLIS

public static CharSequence getRelativeTimeSpanString(long startTime)

public static CharSequence getRelativeTimeSpanString(long time, long now, long minResolution, String prefix, String postfix)

public static final CharSequence timeString(Calendar c)

public static final CharSequence timeString(long millis)

Build m5-rc15i - 10 Jun 2008 13:54