Class ZoneInfo.WallTime
- java.lang.Object
-
- libcore.util.ZoneInfo.WallTime
-
- Enclosing class:
- ZoneInfo
public static class ZoneInfo.WallTime extends Object
A class that represents a "wall time". This class is modeled on the C tm struct and is used to support android.text.format.Time behavior. Unlike the tm struct the year is represented as the full year, not the years since 1900.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
intrather thanlongfor 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 Summary
Constructors Constructor Description WallTime()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetGmtOffset()intgetHour()intgetIsDst()intgetMinute()intgetMonth()intgetMonthDay()intgetSecond()intgetWeekDay()intgetYear()intgetYearDay()voidlocaltime(int timeSeconds, ZoneInfo zoneInfo)Sets the wall time to a point in time using the time zone information provided.intmktime(ZoneInfo zoneInfo)Returns the time in seconds since beginning of the Unix epoch for the wall time using the time zone information provided.voidsetGmtOffset(int gmtoff)voidsetHour(int hour)voidsetIsDst(int isDst)voidsetMinute(int minute)voidsetMonth(int month)voidsetMonthDay(int monthDay)voidsetSecond(int second)voidsetWeekDay(int weekDay)voidsetYear(int year)voidsetYearDay(int yearDay)
-
-
-
Method Detail
-
localtime
public void localtime(int timeSeconds, ZoneInfo zoneInfo)Sets the wall time to a point in time using the time zone information provided. This is a replacement for the old native localtime_tz() function.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.
-
mktime
public 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. This is a replacement for an old native mktime_tz() C function.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:
- t1 { time = 1, offset = 0 }
- t2 { time = 2, offset = -1 }
- t3 { time = 3, offset = -2 }
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.
-
setYear
public void setYear(int year)
-
setMonth
public void setMonth(int month)
-
setMonthDay
public void setMonthDay(int monthDay)
-
setHour
public void setHour(int hour)
-
setMinute
public void setMinute(int minute)
-
setSecond
public void setSecond(int second)
-
setWeekDay
public void setWeekDay(int weekDay)
-
setYearDay
public void setYearDay(int yearDay)
-
setIsDst
public void setIsDst(int isDst)
-
setGmtOffset
public void setGmtOffset(int gmtoff)
-
getYear
public int getYear()
-
getMonth
public int getMonth()
-
getMonthDay
public int getMonthDay()
-
getHour
public int getHour()
-
getMinute
public int getMinute()
-
getSecond
public int getSecond()
-
getWeekDay
public int getWeekDay()
-
getYearDay
public int getYearDay()
-
getGmtOffset
public int getGmtOffset()
-
getIsDst
public int getIsDst()
-
-