Package com.ibm.icu.util
Class TimeZoneRule
- java.lang.Object
-
- com.ibm.icu.util.TimeZoneRule
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
AnnualTimeZoneRule
,InitialTimeZoneRule
,TimeArrayTimeZoneRule
public abstract class TimeZoneRule extends java.lang.Object implements java.io.Serializable
TimeZoneRule
is an abstract class representing a rule for time zone.TimeZoneRule
has a set of time zone attributes, such as zone name, raw offset (UTC offset for standard time) and daylight saving time offset.- See Also:
TimeZoneTransition
,RuleBasedTimeZone
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TimeZoneRule(java.lang.String name, int rawOffset, int dstSavings)
Constructs aTimeZoneRule
with the name, the GMT offset of its standard time and the amount of daylight saving offset adjustment.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
getDSTSavings()
Gets the amount of daylight saving delta time from the standard time.abstract java.util.Date
getFinalStart(int prevRawOffset, int prevDSTSavings)
Gets the final time when this rule takes effect.abstract java.util.Date
getFirstStart(int prevRawOffset, int prevDSTSavings)
Gets the very first time when this rule takes effect.java.lang.String
getName()
Gets the name of this time zone.abstract java.util.Date
getNextStart(long base, int prevRawOffset, int prevDSTSavings, boolean inclusive)
Gets the first time when this rule takes effect after the specified time.abstract java.util.Date
getPreviousStart(long base, int prevRawOffset, int prevDSTSavings, boolean inclusive)
Gets the most recent time when this rule takes effect before the specified time.int
getRawOffset()
Gets the standard time offset.boolean
isEquivalentTo(TimeZoneRule other)
Returns if this rule represents the same rule and offsets as another.abstract boolean
isTransitionRule()
Returns if thisTimeZoneRule
has one or more start times.java.lang.String
toString()
Returns aString
representation of thisTimeZoneRule
object.
-
-
-
Constructor Detail
-
TimeZoneRule
public TimeZoneRule(java.lang.String name, int rawOffset, int dstSavings)
Constructs aTimeZoneRule
with the name, the GMT offset of its standard time and the amount of daylight saving offset adjustment.- Parameters:
name
- The time zone name.rawOffset
- The UTC offset of its standard time in milliseconds.dstSavings
- The amount of daylight saving offset adjustment in milliseconds. If this is a rule for standard time, the value of this argument is 0.
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the name of this time zone.- Returns:
- The name of this time zone.
-
getRawOffset
public int getRawOffset()
Gets the standard time offset.- Returns:
- The standard time offset from UTC in milliseconds.
-
getDSTSavings
public int getDSTSavings()
Gets the amount of daylight saving delta time from the standard time.- Returns:
- The amount of daylight saving offset used by this rule in milliseconds.
-
isEquivalentTo
public boolean isEquivalentTo(TimeZoneRule other)
Returns if this rule represents the same rule and offsets as another. When twoTimeZoneRule
objects differ only its names, this method returns true.- Parameters:
other
- TheTimeZoneRule
object to be compared with.- Returns:
- true if the other
TimeZoneRule
is the same as this one.
-
getFirstStart
public abstract java.util.Date getFirstStart(int prevRawOffset, int prevDSTSavings)
Gets the very first time when this rule takes effect.- Parameters:
prevRawOffset
- The standard time offset from UTC before this rule takes effect in milliseconds.prevDSTSavings
- The amount of daylight saving offset from the standard time.- Returns:
- The very first time when this rule takes effect.
-
getFinalStart
public abstract java.util.Date getFinalStart(int prevRawOffset, int prevDSTSavings)
Gets the final time when this rule takes effect.- Parameters:
prevRawOffset
- The standard time offset from UTC before this rule takes effect in milliseconds.prevDSTSavings
- The amount of daylight saving offset from the standard time.- Returns:
- The very last time when this rule takes effect, or null if this rule is applied for future dates infinitely.
-
getNextStart
public abstract java.util.Date getNextStart(long base, int prevRawOffset, int prevDSTSavings, boolean inclusive)
Gets the first time when this rule takes effect after the specified time.- Parameters:
base
- The first time after this time is returned.prevRawOffset
- The standard time offset from UTC before this rule takes effect in milliseconds.prevDSTSavings
- The amount of daylight saving offset from the standard time.inclusive
- Whether the base time is inclusive or not.- Returns:
- The first time when this rule takes effect after the specified time, or null when this rule never takes effect after the specified time.
-
getPreviousStart
public abstract java.util.Date getPreviousStart(long base, int prevRawOffset, int prevDSTSavings, boolean inclusive)
Gets the most recent time when this rule takes effect before the specified time.- Parameters:
base
- The most recent time when this rule takes effect before this time is returned.prevRawOffset
- The standard time offset from UTC before this rule takes effect in milliseconds.prevDSTSavings
- The amount of daylight saving offset from the standard time.inclusive
- Whether the base time is inclusive or not.- Returns:
- The most recent time when this rule takes effect before the specified time, or null when this rule never takes effect before the specified time.
-
isTransitionRule
public abstract boolean isTransitionRule()
Returns if thisTimeZoneRule
has one or more start times.- Returns:
- true if this
TimeZoneRule
has one or more start times.
-
toString
public java.lang.String toString()
Returns aString
representation of thisTimeZoneRule
object. This method is used for debugging purpose only. The string representation can be changed in future version of ICU without any notice.- Overrides:
toString
in classjava.lang.Object
-
-