Package libcore.util

Class ZoneInfo

java.lang.Object
java.util.TimeZone
libcore.util.ZoneInfo
All Implemented Interfaces:
Serializable, Cloneable

public final class ZoneInfo
extends TimeZone
Our concrete TimeZone implementation, backed by zoneinfo data.
See Also:
Serialized Form
  • Method Details

    • makeTimeZone

      public static TimeZone makeTimeZone​(String id, BufferIterator it)
    • getOffset

      public int getOffset​(int era, int year, int month, int day, int dayOfWeek, int millis)
      Description copied from class: TimeZone
      Returns this time zone's offset in milliseconds from UTC at the specified date and time. The offset includes daylight savings time if the date and time is within the daylight savings time period.

      This method is intended to be used by Calendar to compute Calendar.DST_OFFSET and Calendar.ZONE_OFFSET. Application code should have no reason to call this method directly. Each parameter is interpreted in the same way as the corresponding Calendar field. Refer to Calendar for specific definitions of this method's parameters.

      Specified by:
      getOffset in class TimeZone
    • getOffset

      public int getOffset​(long when)
      Description copied from class: TimeZone
      Returns the offset in milliseconds from UTC for this time zone at time. The offset includes daylight savings time if the specified date is within the daylight savings time period.
      Overrides:
      getOffset in class TimeZone
      Parameters:
      when - the date in milliseconds since January 1, 1970 00:00:00 UTC
    • inDaylightTime

      public boolean inDaylightTime​(Date time)
      Description copied from class: TimeZone
      Returns true if time is in a daylight savings time period for this time zone.
      Specified by:
      inDaylightTime in class TimeZone
    • getRawOffset

      public int getRawOffset()
      Description copied from class: TimeZone
      Returns the offset in milliseconds from UTC of this time zone's standard time.
      Specified by:
      getRawOffset in class TimeZone
    • setRawOffset

      public void setRawOffset​(int off)
      Description copied from class: TimeZone
      Sets the offset in milliseconds from UTC of this time zone's standard time.
      Specified by:
      setRawOffset in class TimeZone
    • getDSTSavings

      public int getDSTSavings()
      Description copied from class: TimeZone
      Returns the latest daylight savings in milliseconds for this time zone, relative to this time zone's regular UTC offset (as returned by TimeZone.getRawOffset()).

      This class returns 3600000 (1 hour) for time zones that use daylight savings time and 0 for timezones that do not, leaving it to subclasses to override this method for other daylight savings offsets. (There are time zones, such as Australia/Lord_Howe, that use other values.)

      Note that this method doesn't tell you whether or not to apply the offset: you need to call inDaylightTime for the specific time you're interested in. If this method returns a non-zero offset, that only tells you that this TimeZone sometimes observes daylight savings.

      Note also that this method doesn't necessarily return the value you need to apply to the time you're working with. This value can and does change over time for a given time zone.

      It's highly unlikely that you should ever call this method. You probably want TimeZone.getOffset(long) instead, which tells you the offset for a specific point in time, and takes daylight savings into account for you.

      Overrides:
      getDSTSavings in class TimeZone
    • useDaylightTime

      public boolean useDaylightTime()
      Description copied from class: TimeZone
      Returns true if this time zone has a future transition to or from daylight savings time.

      Warning: this returns false for time zones like Asia/Kuala_Lumpur that have previously used DST but do not currently. A hypothetical country that has never observed daylight savings before but plans to start next year would return true.

      Warning: this returns true for time zones that use DST, even when it is not active.

      Use TimeZone.inDaylightTime(java.util.Date) to find out whether daylight savings is in effect at a specific time.

      Most applications should not use this method.

      Specified by:
      useDaylightTime in class TimeZone
    • hasSameRules

      public boolean hasSameRules​(TimeZone timeZone)
      Description copied from class: TimeZone
      Returns true if timeZone has the same rules as this time zone.

      The base implementation returns true if both time zones have the same raw offset.

      Overrides:
      hasSameRules in class TimeZone
    • equals

      public boolean equals​(Object obj)
      Description copied from class: Object
      Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.

      The default implementation returns true only if this == o. See Writing a correct equals method if you intend implementing your own equals method.

      The general contract for the equals and Object.hashCode() methods is that if equals returns true for any two objects, then hashCode() must return the same value for these objects. This means that subclasses of Object usually override either both methods or neither of them.

      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare this instance with.
      Returns:
      true if the specified object is equal to this Object; false otherwise.
      See Also:
      Object.hashCode()
    • hashCode

      public int hashCode()
      Description copied from class: Object
      Returns an integer hash code for this object. By contract, any two objects for which Object.equals(java.lang.Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

      Note that hash values must not change over time unless information used in equals comparisons also changes.

      See Writing a correct hashCode method if you intend implementing your own hashCode method.

      Overrides:
      hashCode in class Object
      Returns:
      this object's hash code.
      See Also:
      Object.equals(java.lang.Object)
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
         getClass().getName() + '@' + Integer.toHexString(hashCode())

      See Writing a useful toString method if you intend implementing your own toString method.

      Overrides:
      toString in class Object
      Returns:
      a printable representation of this object.