Class ZoneInfo
- All Implemented Interfaces:
Serializable,Cloneable
public final class ZoneInfo extends TimeZone
- See Also:
- Serialized Form
-
Field Summary
-
Method Summary
Modifier and Type Method Description booleanequals(Object obj)Compares this instance with the specified object and indicates if they are equal.intgetDSTSavings()Returns the latest daylight savings in milliseconds for this time zone, relative to this time zone's regular UTC offset (as returned byTimeZone.getRawOffset()).intgetOffset(int era, int year, int month, int day, int dayOfWeek, int millis)Returns this time zone's offset in milliseconds from UTC at the specified date and time.intgetOffset(long when)Returns the offset in milliseconds from UTC for this time zone attime.intgetRawOffset()Returns the offset in milliseconds from UTC of this time zone's standard time.inthashCode()Returns an integer hash code for this object.booleanhasSameRules(TimeZone timeZone)Returns true iftimeZonehas the same rules as this time zone.booleaninDaylightTime(Date time)Returns true iftimeis in a daylight savings time period for this time zone.static TimeZonemakeTimeZone(String id, BufferIterator it)voidsetRawOffset(int off)Sets the offset in milliseconds from UTC of this time zone's standard time.StringtoString()Returns a string containing a concise, human-readable description of this object.booleanuseDaylightTime()Returns true if this time zone has a future transition to or from daylight savings time.Methods inherited from class java.util.TimeZone
clone, getAvailableIDs, getAvailableIDs, getDefault, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getID, getTimeZone, setDefault, setID
-
Method Details
-
makeTimeZone
-
getOffset
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)Description copied from class:TimeZoneReturns 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
Calendarto computeCalendar.DST_OFFSETandCalendar.ZONE_OFFSET. Application code should have no reason to call this method directly. Each parameter is interpreted in the same way as the correspondingCalendarfield. Refer toCalendarfor specific definitions of this method's parameters. -
getOffset
public int getOffset(long when)Description copied from class:TimeZoneReturns the offset in milliseconds from UTC for this time zone attime. The offset includes daylight savings time if the specified date is within the daylight savings time period. -
inDaylightTime
Description copied from class:TimeZoneReturns true iftimeis in a daylight savings time period for this time zone.- Specified by:
inDaylightTimein classTimeZone
-
getRawOffset
public int getRawOffset()Description copied from class:TimeZoneReturns the offset in milliseconds from UTC of this time zone's standard time.- Specified by:
getRawOffsetin classTimeZone
-
setRawOffset
public void setRawOffset(int off)Description copied from class:TimeZoneSets the offset in milliseconds from UTC of this time zone's standard time.- Specified by:
setRawOffsetin classTimeZone
-
getDSTSavings
public int getDSTSavings()Description copied from class:TimeZoneReturns the latest daylight savings in milliseconds for this time zone, relative to this time zone's regular UTC offset (as returned byTimeZone.getRawOffset()).This class returns
3600000(1 hour) for time zones that use daylight savings time and0for timezones that do not, leaving it to subclasses to override this method for other daylight savings offsets. (There are time zones, such asAustralia/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
inDaylightTimefor the specific time you're interested in. If this method returns a non-zero offset, that only tells you that thisTimeZonesometimes 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:
getDSTSavingsin classTimeZone
-
useDaylightTime
public boolean useDaylightTime()Description copied from class:TimeZoneReturns 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_Lumpurthat 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:
useDaylightTimein classTimeZone
-
hasSameRules
Description copied from class:TimeZoneReturns true iftimeZonehas the same rules as this time zone.The base implementation returns true if both time zones have the same raw offset.
- Overrides:
hasSameRulesin classTimeZone
-
equals
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust 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
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
obj- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually 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
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
toString
Description copied from class:ObjectReturns 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
toStringmethod if you intend implementing your owntoStringmethod.
-