public static class ZoneInfo.WallTime extends Object
This class contains a rewrite of various native functions that android.text.format.Time once relied on such as mktime_tz and localtime_tz. This replacement does not support leap seconds but does try to preserve behavior around ambiguous date/times found in the BSD version of mktime that was previously used.
The original native code used a 32-bit value for time_t on 32-bit Android, which
was the only variant of Android available at the time. To preserve old behavior this code
deliberately uses int rather than long for most things and performs
calculations in seconds. This creates deliberate truncation issues for date / times before
1901 and after 2038. This is intentional but might be fixed in future if all the knock-ons
can be resolved: Application code may have come to rely on the range so previously values
like zero for year could indicate an invalid date but if we move to long the year zero would
be valid.
All offsets are considered to be safe for addition / subtraction / multiplication without worrying about overflow. All absolute time arithmetic is checked for overflow / underflow.
| Constructor and Description |
|---|
WallTime() |
| Modifier and Type | Method and Description |
|---|---|
int |
getGmtOffset() |
int |
getHour() |
int |
getIsDst() |
int |
getMinute() |
int |
getMonth() |
int |
getMonthDay() |
int |
getSecond() |
int |
getWeekDay() |
int |
getYear() |
int |
getYearDay() |
void |
localtime(int timeSeconds,
ZoneInfo zoneInfo)
Sets the wall time to a point in time using the time zone information provided.
|
int |
mktime(ZoneInfo zoneInfo)
Returns the time in seconds since beginning of the Unix epoch for the wall time using the
time zone information provided.
|
void |
setGmtOffset(int gmtoff) |
void |
setHour(int hour) |
void |
setIsDst(int isDst) |
void |
setMinute(int minute) |
void |
setMonth(int month) |
void |
setMonthDay(int monthDay) |
void |
setSecond(int second) |
void |
setWeekDay(int weekDay) |
void |
setYear(int year) |
void |
setYearDay(int yearDay) |
public void localtime(int timeSeconds,
ZoneInfo zoneInfo)
When going from an instant to a wall time it is always unambiguous because there is only one offset rule acting at any given instant. We do not consider leap seconds.
public int mktime(ZoneInfo zoneInfo)
When going from a wall time to an instant the answer can be ambiguous. A wall time can map to zero, one or two instants given sane date/time transitions. Sane in this case means that transitions occur less frequently than the offset differences between them (which could cause all sorts of craziness like the skipping out of transitions).
For example, this is not fully supported:
We do not handle leap seconds.
We assume that no timezone offset transition has an absolute offset > 24 hours.
We do not assume that adjacent transitions modify the DST state; adjustments can occur for other reasons such as when a zone changes its raw offset.
public void setYear(int year)
public void setMonth(int month)
public void setMonthDay(int monthDay)
public void setHour(int hour)
public void setMinute(int minute)
public void setSecond(int second)
public void setWeekDay(int weekDay)
public void setYearDay(int yearDay)
public void setIsDst(int isDst)
public void setGmtOffset(int gmtoff)
public int getYear()
public int getMonth()
public int getMonthDay()
public int getHour()
public int getMinute()
public int getSecond()
public int getWeekDay()
public int getYearDay()
public int getGmtOffset()
public int getIsDst()