Top Description Fields Constructors Methods
net.fortuna.ical4j.model

public Class TimeZone

extends TimeZone
Class Inheritance
Imports
net.fortuna.ical4j.model.component.Daylight, .Observance, .Standard, .VTimeZone, net.fortuna.ical4j.model.property.TzId, .TzOffsetFrom, .TzOffsetTo, net.fortuna.ical4j.util.CompatibilityHints, org.slf4j.Logger, .LoggerFactory, java.time.Instant, .OffsetDateTime, .ZoneOffset, java.util.Date, .List, .Objects, .Optional

$Id$

Created on 13/09/2005

A Java timezone implementation based on an underlying VTimeZone definition.

Author
Ben Fortuna

Field Summary

Modifier and TypeField and Description
private static final Logger
private final boolean
private final int
private static final long
private final VTimeZone
Inherited from java.util.TimeZone:
LONGSHORT

Constructor Summary

AccessConstructor and Description
public
TimeZone(final VTimeZone
a VTIMEZONE object instance
vTimeZone
)

Constructs a new instance based on the specified VTimeZone.

public
TimeZone(final VTimeZone vTimeZone, boolean negativeDstSupported)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public final int
getOffset(final int
the era of the given date.
era
,
final int
the year in the given date.
year
,
final int
the month in the given date. Month is 0-based. e.g., 0 for January.
month
,
final int
the day-in-month of the given date.
dayOfMonth
,
final int
the day-of-week of the given date.
dayOfWeek
,
final int
the milliseconds in day in standard local time.
milliseconds
)

Implements abstract java.util.TimeZone.getOffset.

Gets the time zone offset, for current date, modified in case of daylight savings.

public int
getOffset(long
the date represented in milliseconds since January 1, 1970 00:00:00 GMT
date
)

Overrides java.util.TimeZone.getOffset.

Returns the offset of this time zone from UTC at the specified date.

public final int
getRawOffset()

Implements abstract java.util.TimeZone.getRawOffset.

Returns the amount of time in milliseconds to add to UTC to get standard time in this time zone.

private static int
public final VTimeZone

Returns:

Returns the VTimeZone backing this instance.
getVTimeZone
()

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public final boolean

Returns:

true if the specified date is in daylight time, otherwise false
inDaylightTime
(final Date
a date instance
date
)

Implements abstract java.util.TimeZone.inDaylightTime.

Determines if the specified date is in daylight time according to this timezone.

private boolean
public final void
setRawOffset(final int
the given base time zone offset to GMT.
offsetMillis
)

Implements abstract java.util.TimeZone.setRawOffset.

Sets the base time zone offset to GMT.

public final boolean
useDaylightTime()

Implements abstract java.util.TimeZone.useDaylightTime.

Queries if this TimeZone uses Daylight Saving Time.

Inherited from java.util.TimeZone:
clonegetAvailableIDsgetAvailableIDsgetDefaultgetDisplayNamegetDisplayNamegetDisplayNamegetDisplayNamegetDSTSavingsgetIDgetTimeZonegetTimeZonehasSameRulesobservesDaylightTimesetDefaultsetIDtoZoneId

Field Detail

LOGback to summary
private static final Logger LOG
negativeDstSupportedback to summary
private final boolean negativeDstSupported
rawOffsetback to summary
private final int rawOffset
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.TimeZone.serialVersionUID.

vTimeZoneback to summary
private final VTimeZone vTimeZone

Constructor Detail

TimeZoneback to summary
public TimeZone(final VTimeZone vTimeZone)

Constructs a new instance based on the specified VTimeZone.

Parameters
vTimeZone:VTimeZone

a VTIMEZONE object instance

TimeZoneback to summary
public TimeZone(final VTimeZone vTimeZone, boolean negativeDstSupported)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getOffsetback to summary
public final int getOffset(final int era, final int year, final int month, final int dayOfMonth, final int dayOfWeek, final int milliseconds)

Implements abstract java.util.TimeZone.getOffset.

Doc from java.util.TimeZone.getOffset.

Gets the time zone offset, for current date, modified in case of daylight savings. This is the offset to add to UTC to get local time.

This method returns a historically correct offset if an underlying TimeZone implementation subclass supports historical Daylight Saving Time schedule and GMT offset changes.

Parameters
era:int

the era of the given date.

year:int

the year in the given date.

month:int

the month in the given date. Month is 0-based. e.g., 0 for January.

dayOfMonth:int

the day-in-month of the given date.

dayOfWeek:int

the day-of-week of the given date.

milliseconds:int

the milliseconds in day in standard local time.

Returns:int

the offset in milliseconds to add to GMT to get local time.

Annotations
@Override
getOffsetback to summary
public int getOffset(long date)

Overrides java.util.TimeZone.getOffset.

Doc from java.util.TimeZone.getOffset.

Returns the offset of this time zone from UTC at the specified date. If Daylight Saving Time is in effect at the specified date, the offset value is adjusted with the amount of daylight saving.

This method returns a historically correct offset value if an underlying TimeZone implementation subclass supports historical Daylight Saving Time schedule and GMT offset changes.

Parameters
date:long

the date represented in milliseconds since January 1, 1970 00:00:00 GMT

Returns:int

the amount of time in milliseconds to add to UTC to get local time.

Annotations
@Override
getRawOffsetback to summary
public final int getRawOffset()

Implements abstract java.util.TimeZone.getRawOffset.

Doc from java.util.TimeZone.getRawOffset.

Returns the amount of time in milliseconds to add to UTC to get standard time in this time zone. Because this value is not affected by daylight saving time, it is called raw offset.

If an underlying TimeZone implementation subclass supports historical GMT offset changes, the method returns the raw offset value of the current date. In Honolulu, for example, its raw offset changed from GMT-10:30 to GMT-10:00 in 1947, and this method always returns -36000000 milliseconds (i.e., -10 hours).

Returns:int

the amount of raw offset time in milliseconds to add to UTC.

Annotations
@Override
getRawOffsetback to summary
private static int getRawOffset(VTimeZone vt)
getVTimeZoneback to summary
public final VTimeZone getVTimeZone()
Returns:VTimeZone

Returns the VTimeZone backing this instance.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
inDaylightTimeback to summary
public final boolean inDaylightTime(final Date date)

Implements abstract java.util.TimeZone.inDaylightTime.

Determines if the specified date is in daylight time according to this timezone. This is done by finding the latest supporting observance for the specified date and identifying whether it is daylight time.

Parameters
date:Date

a date instance

Returns:boolean

true if the specified date is in daylight time, otherwise false

Annotations
@Override
isNegativeOffsetback to summary
private boolean isNegativeOffset(Observance observance)
setRawOffsetback to summary
public final void setRawOffset(final int offsetMillis)

Implements abstract java.util.TimeZone.setRawOffset.

Doc from java.util.TimeZone.setRawOffset.

Sets the base time zone offset to GMT. This is the offset to add to UTC to get local time.

If an underlying TimeZone implementation subclass supports historical GMT offset changes, the specified GMT offset is set as the latest GMT offset and the difference from the known latest GMT offset value is used to adjust all historical GMT offset values.

Parameters
offsetMillis:int

the given base time zone offset to GMT.

Annotations
@Override
useDaylightTimeback to summary
public final boolean useDaylightTime()

Implements abstract java.util.TimeZone.useDaylightTime.

Doc from java.util.TimeZone.useDaylightTime.

Queries if this TimeZone uses Daylight Saving Time.

If an underlying TimeZone implementation subclass supports historical and future Daylight Saving Time schedule changes, this method refers to the last known Daylight Saving Time rule that can be a future prediction and may not be the same as the current rule. Consider calling observesDaylightTime() if the current rule should also be taken into account.

Returns:boolean

true if this TimeZone uses Daylight Saving Time, false, otherwise.

Annotations
@Override