public final class ZoneInfo extends TimeZone
| Modifier and Type | Class and Description |
|---|---|
static class |
ZoneInfo.WallTime
A class that represents a "wall time".
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Returns a new time zone with the same ID, raw offset, and daylight
savings time rules as this time zone.
|
boolean |
equals(Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
int |
getDSTSavings()
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()). |
int |
getOffset(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.
|
int |
getOffset(long when)
Returns the offset in milliseconds from UTC for this time zone at
time. |
int |
getRawOffset()
Returns the offset in milliseconds from UTC of this time zone's standard
time.
|
int |
hashCode()
Returns an integer hash code for this object.
|
boolean |
hasSameRules(TimeZone timeZone)
Returns true if
timeZone has the same rules as this time zone. |
boolean |
inDaylightTime(Date time)
Returns true if
time is in a daylight savings time period for
this time zone. |
static ZoneInfo |
makeTimeZone(String id,
BufferIterator it) |
void |
setRawOffset(int off)
Sets the offset in milliseconds from UTC of this time zone's standard
time.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
boolean |
useDaylightTime()
Returns true if this time zone has a future transition to or from
daylight savings time.
|
createGmtOffsetString, getAvailableIDs, getAvailableIDs, getDefault, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getID, getTimeZone, getTimeZone, setDefault, setID, toZoneIdpublic static ZoneInfo makeTimeZone(String id, BufferIterator it)
public int getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int millis)
TimeZoneThis 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.
public int getOffset(long when)
TimeZonetime. The offset includes daylight savings time if the specified
date is within the daylight savings time period.public boolean inDaylightTime(Date time)
TimeZonetime is in a daylight savings time period for
this time zone.inDaylightTime in class TimeZonepublic int getRawOffset()
TimeZonegetRawOffset in class TimeZonepublic void setRawOffset(int off)
TimeZonesetRawOffset in class TimeZonepublic int getDSTSavings()
TimeZoneTimeZone.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.
getDSTSavings in class TimeZonepublic boolean useDaylightTime()
TimeZoneWarning: 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.
useDaylightTime in class TimeZonepublic boolean hasSameRules(TimeZone timeZone)
TimeZonetimeZone has the same rules as this time zone.
The base implementation returns true if both time zones have the same raw offset.
hasSameRules in class TimeZonepublic boolean equals(Object obj)
Objecto 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.
equals in class Objectobj - the object to compare this instance with.true if the specified object is equal to this Object; false otherwise.Object.hashCode()public int hashCode()
ObjectObject.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.
hashCode in class ObjectObject.equals(java.lang.Object)public String toString()
ObjectgetClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString method
if you intend implementing your own toString method.