public class TimeUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
HUNDRED_DAY_FIELD_LEN |
static long |
NANOS_PER_MS |
Constructor and Description |
---|
TimeUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
formatDuration(long time,
long now,
PrintWriter pw) |
static void |
formatDuration(long duration,
PrintWriter pw) |
static void |
formatDuration(long duration,
PrintWriter pw,
int fieldLen) |
static void |
formatDuration(long duration,
StringBuilder builder) |
static String |
formatForLogging(long millis) |
static String |
formatUptime(long time) |
static TimeZone |
getTimeZone(int offset,
boolean dst,
long when,
String country)
Tries to return a time zone that would have had the specified offset
and DST value at the specified moment in the specified country.
|
static String |
getTimeZoneDatabaseVersion()
Returns a String indicating the version of the time zone database currently
in use.
|
static ArrayList<TimeZone> |
getTimeZones(String country)
Returns the time zones for the country, which is the code
attribute of the timezone element in time_zones_by_country.xml.
|
static ArrayList<TimeZone> |
getTimeZonesWithUniqueOffsets(String country)
Return list of unique time zones for the country.
|
static String |
logTimeOfDay(long millis)
Convert a System.currentTimeMillis() value to a time of day value like
that printed in logs.
|
public static final int HUNDRED_DAY_FIELD_LEN
public static final long NANOS_PER_MS
public static TimeZone getTimeZone(int offset, boolean dst, long when, String country)
public static ArrayList<TimeZone> getTimeZonesWithUniqueOffsets(String country)
country
- to findpublic static ArrayList<TimeZone> getTimeZones(String country)
country
- is a two character country code.public static String getTimeZoneDatabaseVersion()
Time zone database updates should be expected to occur periodically due to political and legal changes that cannot be anticipated in advance. Therefore, when computing the UTC time for a future event, applications should be aware that the results may differ following a time zone database update. This method allows applications to detect that a database change has occurred, and to recalculate any cached times accordingly.
The time zone database may be assumed to change only when the device runtime is restarted. Therefore, it is not necessary to re-query the database version during the lifetime of an activity.
public static void formatDuration(long duration, StringBuilder builder)
public static void formatDuration(long duration, PrintWriter pw, int fieldLen)
public static void formatDuration(long duration, PrintWriter pw)
public static void formatDuration(long time, long now, PrintWriter pw)
public static String formatUptime(long time)
public static String logTimeOfDay(long millis)
millis
- since the epoch (1/1/1970)public static String formatForLogging(long millis)