Top Description Fields Constructors Methods
org.apache.commons.lang3.time

pack-priv final Class GmtTimeZone

extends TimeZone
Class Inheritance
Imports
java.util.Date, .Objects, .TimeZone

Custom time zone that contains offset from GMT.
Since
3.7

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private final int
pack-priv static final long
private final String
Inherited from java.util.TimeZone:
LONGSHORT

Constructor Summary

AccessConstructor and Description
pack-priv
GmtTimeZone(final boolean negate, final int hours, final int minutes)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object obj)

Overrides java.lang.Object.equals.

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

public String
getID()

Overrides java.util.TimeZone.getID.

Gets the ID of this time zone.

public int
getOffset(final int era, final int year, final int month, final int day, final int dayOfWeek, final int milliseconds)

Implements abstract java.util.TimeZone.getOffset.

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

public 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.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
inDaylightTime(final Date date)

Implements abstract java.util.TimeZone.inDaylightTime.

Queries if the given date is in Daylight Saving Time in this time zone.

public void
setRawOffset(final int offsetMillis)

Implements abstract java.util.TimeZone.setRawOffset.

Sets the base time zone offset to GMT.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private static StringBuilder
twoDigits(final StringBuilder sb, final int n)

public boolean
useDaylightTime()

Implements abstract java.util.TimeZone.useDaylightTime.

Queries if this TimeZone uses Daylight Saving Time.

Inherited from java.util.TimeZone:
availableIDsavailableIDsclonegetAvailableIDsgetAvailableIDsgetDefaultgetDisplayNamegetDisplayNamegetDisplayNamegetDisplayNamegetDSTSavingsgetOffsetgetTimeZonegetTimeZonehasSameRulesobservesDaylightTimesetDefaultsetIDtoZoneId

Field Detail

HOURS_PER_DAYback to summary
private static final int HOURS_PER_DAY
MILLISECONDS_PER_MINUTEback to summary
private static final int MILLISECONDS_PER_MINUTE
MINUTES_PER_HOURback to summary
private static final int MINUTES_PER_HOUR
offsetback to summary
private final int offset
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.util.TimeZone.serialVersionUID.

zoneIdback to summary
private final String zoneId

Hides java.util.TimeZone.zoneId.

Constructor Detail

GmtTimeZoneback to summary
pack-priv GmtTimeZone(final boolean negate, final int hours, final int minutes)

Method Detail

equalsback to summary
public boolean equals(final Object obj)

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.

Annotations
@Override
getIDback to summary
public String getID()

Overrides java.util.TimeZone.getID.

Doc from java.util.TimeZone.getID.

Gets the ID of this time zone.

Annotations
@Override
getOffsetback to summary
public int getOffset(final int era, final int year, final int month, final int day, 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.

Annotations
@Override
getRawOffsetback to summary
public 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).

Annotations
@Override
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.
Annotations
@Override
inDaylightTimeback to summary
public boolean inDaylightTime(final Date date)

Implements abstract java.util.TimeZone.inDaylightTime.

Doc from java.util.TimeZone.inDaylightTime.

Queries if the given date is in Daylight Saving Time in this time zone.

Annotations
@Override
setRawOffsetback to summary
public 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.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
twoDigitsback to summary
private static StringBuilder twoDigits(final StringBuilder sb, final int n)
useDaylightTimeback to summary
public 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.

Annotations
@Override