Class VTimeZone
- java.lang.Object
-
- com.ibm.icu.util.TimeZone
-
- com.ibm.icu.util.BasicTimeZone
-
- com.ibm.icu.util.VTimeZone
-
public class VTimeZone extends BasicTimeZone
VTimeZone
is a class implementing RFC2445 VTIMEZONE. You can create aVTimeZone
instance from a time zone ID supported byTimeZone
. With theVTimeZone
instance created from the ID, you can write out the rule in RFC2445 VTIMEZONE format. Also, you can create aVTimeZone
instance from RFC2445 VTIMEZONE data stream, which allows you to calculate time zone offset by the rules defined by the data.
Note: The consumer of this class reading or writing VTIMEZONE data is responsible to decode or encode Non-ASCII text. Methods reading/writing VTIMEZONE data in this class do nothing with MIME encoding.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.icu.util.BasicTimeZone
BasicTimeZone.LocalOption
-
Nested classes/interfaces inherited from class com.ibm.icu.util.TimeZone
TimeZone.SystemTimeZoneType
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
COLON
private static java.lang.String
COMMA
private static int
DEF_DSTSAVINGS
private static long
DEF_TZSTARTTIME
private static java.lang.String
EQUALS_SIGN
private static int
ERR
private static java.lang.String
ICAL_BEGIN
private static java.lang.String
ICAL_BEGIN_VTIMEZONE
private static java.lang.String
ICAL_BYDAY
private static java.lang.String
ICAL_BYMONTH
private static java.lang.String
ICAL_BYMONTHDAY
private static java.lang.String
ICAL_DAYLIGHT
private static java.lang.String[]
ICAL_DOW_NAMES
private static java.lang.String
ICAL_DTSTART
private static java.lang.String
ICAL_END
private static java.lang.String
ICAL_END_VTIMEZONE
private static java.lang.String
ICAL_FREQ
private static java.lang.String
ICAL_LASTMOD
private static java.lang.String
ICAL_RDATE
private static java.lang.String
ICAL_RRULE
private static java.lang.String
ICAL_STANDARD
private static java.lang.String
ICAL_TZID
private static java.lang.String
ICAL_TZNAME
private static java.lang.String
ICAL_TZOFFSETFROM
private static java.lang.String
ICAL_TZOFFSETTO
private static java.lang.String
ICAL_TZURL
private static java.lang.String
ICAL_UNTIL
private static java.lang.String
ICAL_VTIMEZONE
private static java.lang.String
ICAL_YEARLY
private static java.lang.String
ICU_TZINFO_PROP
private static java.lang.String
ICU_TZVERSION
private static int
INI
private boolean
isFrozen
private java.util.Date
lastmod
private static long
MAX_TIME
private static long
MIN_TIME
private static int[]
MONTHLENGTH
private static java.lang.String
NEWLINE
private java.lang.String
olsonzid
private static java.lang.String
SEMICOLON
private static long
serialVersionUID
private BasicTimeZone
tz
private static int
TZI
private java.lang.String
tzurl
private static int
VTZ
private java.util.List<java.lang.String>
vtzlines
-
Fields inherited from class com.ibm.icu.util.BasicTimeZone
FORMER_LATTER_MASK, LOCAL_DST, LOCAL_FORMER, LOCAL_LATTER, LOCAL_STD, STD_DST_MASK
-
Fields inherited from class com.ibm.icu.util.TimeZone
GENERIC_LOCATION, GMT_ZONE, GMT_ZONE_ID, LONG, LONG_GENERIC, LONG_GMT, SHORT, SHORT_COMMONLY_USED, SHORT_GENERIC, SHORT_GMT, TIMEZONE_ICU, TIMEZONE_JDK, UNKNOWN_ZONE, UNKNOWN_ZONE_ID
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
appendUNTIL(java.io.Writer writer, java.lang.String until)
private static void
beginRRULE(java.io.Writer writer, int month)
private static void
beginZoneProps(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, long startTime)
java.lang.Object
clone()
Overrides clone.TimeZone
cloneAsThawed()
Provides for the clone operation.static VTimeZone
create(java.io.Reader reader)
Create aVTimeZone
instance by RFC2445 VTIMEZONE data.static VTimeZone
create(java.lang.String tzid)
Create aVTimeZone
instance by the time zone ID.private static TimeZoneRule
createRuleByRDATE(java.lang.String tzname, int rawOffset, int dstSavings, long start, java.util.List<java.lang.String> dates, int fromOffset)
private static TimeZoneRule
createRuleByRRULE(java.lang.String tzname, int rawOffset, int dstSavings, long start, java.util.List<java.lang.String> dates, int fromOffset)
private static void
endZoneProps(java.io.Writer writer, boolean isDst)
TimeZone
freeze()
Freezes the object.private static java.lang.String
getDateTimeString(long time)
private static java.lang.String
getDefaultTZName(java.lang.String tzid, boolean isDST)
java.util.Date
getLastModified()
Gets the RFC2445 LAST-MODIFIED property value.TimeZoneTransition
getNextTransition(long base, boolean inclusive)
Returns the first time zone transition after the base time.int
getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds)
Gets the time zone offset, for current date, modified in case of daylight savings.void
getOffset(long date, boolean local, int[] offsets)
Returns the time zone raw and GMT offset for the given moment in time.void
getOffsetFromLocal(long date, BasicTimeZone.LocalOption nonExistingTimeOpt, BasicTimeZone.LocalOption duplicatedTimeOpt, int[] offsets)
Returns time zone offsets from local wall time.TimeZoneTransition
getPreviousTransition(long base, boolean inclusive)
Returns the last time zone transition before the base time.int
getRawOffset()
Gets unmodified offset, NOT modified in case of daylight savings.TimeZoneRule[]
getTimeZoneRules()
Returns the array ofTimeZoneRule
which represents the rule of this time zone object.TimeZoneRule[]
getTimeZoneRules(long start)
Returns the array ofTimeZoneRule
which represents the rule of this time zone object since the specified start time.java.lang.String
getTZURL()
Gets the RFC2445 TZURL property value.private static java.lang.String
getUTCDateTimeString(long time)
boolean
hasEquivalentTransitions(TimeZone other, long start, long end)
Checks if the time zone has equivalent transitions in the time range.boolean
hasSameRules(TimeZone other)
Returns true if this zone has the same rule and offset as another zone.boolean
inDaylightTime(java.util.Date date)
Queries if the given date is in daylight savings time in this time zone.private static boolean
isEquivalentDateRule(int month, int weekInMonth, int dayOfWeek, DateTimeRule dtrule)
boolean
isFrozen()
Determines whether the object has been frozen or not.private boolean
load(java.io.Reader reader)
private static java.lang.String
millisToOffset(int millis)
private static java.lang.String
numToString(int num, int width)
boolean
observesDaylightTime()
Queries if this time zone is in daylight saving time or will observe daylight saving time at any future time.private static int
offsetStrToMillis(java.lang.String str)
private boolean
parse()
private static long
parseDateTimeString(java.lang.String str, int offset)
private static int[]
parseRRULE(java.lang.String rrule, long[] until)
void
setLastModified(java.util.Date date)
Sets the date used for RFC2445 LAST-MODIFIED property value.void
setRawOffset(int offsetMillis)
Sets the base time zone offset to GMT.void
setTZURL(java.lang.String url)
Sets the RFC2445 TZURL property value.private static DateTimeRule
toWallTimeRule(DateTimeRule rule, int rawOffset, int dstSavings)
boolean
useDaylightTime()
Queries if this time zone uses daylight savings time.void
write(java.io.Writer writer)
Writes RFC2445 VTIMEZONE data for this time zonevoid
write(java.io.Writer writer, long start)
Writes RFC2445 VTIMEZONE data applicable for dates after the specified start time.private static void
writeFinalRule(java.io.Writer writer, boolean isDst, AnnualTimeZoneRule rule, int fromRawOffset, int fromDSTSavings, long startTime)
private static void
writeFooter(java.io.Writer writer)
private void
writeHeader(java.io.Writer writer)
void
writeSimple(java.io.Writer writer, long time)
Writes RFC2445 VTIMEZONE data applicable near the specified date.private void
writeZone(java.io.Writer w, BasicTimeZone basictz, java.lang.String[] customProperties)
private static void
writeZonePropsByDOM(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, int month, int dayOfMonth, long startTime, long untilTime)
private static void
writeZonePropsByDOW(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, int month, int weekInMonth, int dayOfWeek, long startTime, long untilTime)
private static void
writeZonePropsByDOW_GEQ_DOM(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, int month, int dayOfMonth, int dayOfWeek, long startTime, long untilTime)
private static void
writeZonePropsByDOW_GEQ_DOM_sub(java.io.Writer writer, int month, int dayOfMonth, int dayOfWeek, int numDays, long untilTime, int fromOffset)
private static void
writeZonePropsByDOW_LEQ_DOM(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, int month, int dayOfMonth, int dayOfWeek, long startTime, long untilTime)
private static void
writeZonePropsByTime(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, long time, boolean withRDATE)
-
Methods inherited from class com.ibm.icu.util.BasicTimeZone
getLocalOptionValue, getSimpleTimeZoneRulesNear, hasEquivalentTransitions
-
Methods inherited from class com.ibm.icu.util.TimeZone
countEquivalentIDs, equals, forLocaleOrDefault, forULocaleOrDefault, getAvailableIDs, getAvailableIDs, getAvailableIDs, getAvailableIDs, getCanonicalID, getCanonicalID, getDefault, getDefaultTimeZoneType, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getDSTSavings, getEquivalentID, getFrozenICUTimeZone, getFrozenTimeZone, getIanaID, getID, getIDForWindowsID, getOffset, getRegion, getTimeZone, getTimeZone, getTZDataVersion, getWindowsID, hashCode, setDefault, setDefaultTimeZoneType, setICUDefault, setID
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
tz
private BasicTimeZone tz
-
vtzlines
private java.util.List<java.lang.String> vtzlines
-
olsonzid
private java.lang.String olsonzid
-
tzurl
private java.lang.String tzurl
-
lastmod
private java.util.Date lastmod
-
ICU_TZVERSION
private static java.lang.String ICU_TZVERSION
-
ICU_TZINFO_PROP
private static final java.lang.String ICU_TZINFO_PROP
- See Also:
- Constant Field Values
-
DEF_DSTSAVINGS
private static final int DEF_DSTSAVINGS
- See Also:
- Constant Field Values
-
DEF_TZSTARTTIME
private static final long DEF_TZSTARTTIME
- See Also:
- Constant Field Values
-
MIN_TIME
private static final long MIN_TIME
- See Also:
- Constant Field Values
-
MAX_TIME
private static final long MAX_TIME
- See Also:
- Constant Field Values
-
COLON
private static final java.lang.String COLON
- See Also:
- Constant Field Values
-
SEMICOLON
private static final java.lang.String SEMICOLON
- See Also:
- Constant Field Values
-
EQUALS_SIGN
private static final java.lang.String EQUALS_SIGN
- See Also:
- Constant Field Values
-
COMMA
private static final java.lang.String COMMA
- See Also:
- Constant Field Values
-
NEWLINE
private static final java.lang.String NEWLINE
- See Also:
- Constant Field Values
-
ICAL_BEGIN_VTIMEZONE
private static final java.lang.String ICAL_BEGIN_VTIMEZONE
- See Also:
- Constant Field Values
-
ICAL_END_VTIMEZONE
private static final java.lang.String ICAL_END_VTIMEZONE
- See Also:
- Constant Field Values
-
ICAL_BEGIN
private static final java.lang.String ICAL_BEGIN
- See Also:
- Constant Field Values
-
ICAL_END
private static final java.lang.String ICAL_END
- See Also:
- Constant Field Values
-
ICAL_VTIMEZONE
private static final java.lang.String ICAL_VTIMEZONE
- See Also:
- Constant Field Values
-
ICAL_TZID
private static final java.lang.String ICAL_TZID
- See Also:
- Constant Field Values
-
ICAL_STANDARD
private static final java.lang.String ICAL_STANDARD
- See Also:
- Constant Field Values
-
ICAL_DAYLIGHT
private static final java.lang.String ICAL_DAYLIGHT
- See Also:
- Constant Field Values
-
ICAL_DTSTART
private static final java.lang.String ICAL_DTSTART
- See Also:
- Constant Field Values
-
ICAL_TZOFFSETFROM
private static final java.lang.String ICAL_TZOFFSETFROM
- See Also:
- Constant Field Values
-
ICAL_TZOFFSETTO
private static final java.lang.String ICAL_TZOFFSETTO
- See Also:
- Constant Field Values
-
ICAL_RDATE
private static final java.lang.String ICAL_RDATE
- See Also:
- Constant Field Values
-
ICAL_RRULE
private static final java.lang.String ICAL_RRULE
- See Also:
- Constant Field Values
-
ICAL_TZNAME
private static final java.lang.String ICAL_TZNAME
- See Also:
- Constant Field Values
-
ICAL_TZURL
private static final java.lang.String ICAL_TZURL
- See Also:
- Constant Field Values
-
ICAL_LASTMOD
private static final java.lang.String ICAL_LASTMOD
- See Also:
- Constant Field Values
-
ICAL_FREQ
private static final java.lang.String ICAL_FREQ
- See Also:
- Constant Field Values
-
ICAL_UNTIL
private static final java.lang.String ICAL_UNTIL
- See Also:
- Constant Field Values
-
ICAL_YEARLY
private static final java.lang.String ICAL_YEARLY
- See Also:
- Constant Field Values
-
ICAL_BYMONTH
private static final java.lang.String ICAL_BYMONTH
- See Also:
- Constant Field Values
-
ICAL_BYDAY
private static final java.lang.String ICAL_BYDAY
- See Also:
- Constant Field Values
-
ICAL_BYMONTHDAY
private static final java.lang.String ICAL_BYMONTHDAY
- See Also:
- Constant Field Values
-
ICAL_DOW_NAMES
private static final java.lang.String[] ICAL_DOW_NAMES
-
MONTHLENGTH
private static final int[] MONTHLENGTH
-
INI
private static final int INI
- See Also:
- Constant Field Values
-
VTZ
private static final int VTZ
- See Also:
- Constant Field Values
-
TZI
private static final int TZI
- See Also:
- Constant Field Values
-
ERR
private static final int ERR
- See Also:
- Constant Field Values
-
isFrozen
private transient volatile boolean isFrozen
-
-
Method Detail
-
create
public static VTimeZone create(java.lang.String tzid)
Create aVTimeZone
instance by the time zone ID.- Parameters:
tzid
- The time zone ID, such as America/New_York- Returns:
- A
VTimeZone
initialized by the time zone ID, or null when the ID is unknown.
-
create
public static VTimeZone create(java.io.Reader reader)
Create aVTimeZone
instance by RFC2445 VTIMEZONE data.- Parameters:
reader
- The Reader for VTIMEZONE data input stream- Returns:
- A
VTimeZone
initialized by the VTIMEZONE data or null if failed to load the rule from the VTIMEZONE data.
-
getOffset
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds)
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.- Specified by:
getOffset
in classTimeZone
- Parameters:
era
- the era of the given date.year
- the year in the given date.month
- the month in the given date. Month is 0-based. e.g., 0 for January.day
- the day-in-month of the given date.dayOfWeek
- the day-of-week of the given date.milliseconds
- the millis in day in standard local time.- Returns:
- the offset to add to GMT to get local time.
-
getOffset
public void getOffset(long date, boolean local, int[] offsets)
Returns the time zone raw and GMT offset for the given moment in time. Upon return, local-millis = GMT-millis + rawOffset + dstOffset. All computations are performed in the proleptic Gregorian calendar. The default implementation in the TimeZone class delegates to the 8-argument getOffset().- Overrides:
getOffset
in classTimeZone
- Parameters:
date
- moment in time for which to return offsets, in units of milliseconds from January 1, 1970 0:00 GMT, either GMT time or local wall time, depending onlocal
.local
- if true,date
is local wall time; otherwise it is in GMT time.offsets
- output parameter to receive the raw offset, that is, the offset not including DST adjustments, in offsets[0], and the DST offset, that is, the offset to be added torawOffset
to obtain the total offset between local and GMT time, in offsets[1]. If DST is not in effect, the DST offset is zero; otherwise it is a positive value, typically one hour.
-
getOffsetFromLocal
public void getOffsetFromLocal(long date, BasicTimeZone.LocalOption nonExistingTimeOpt, BasicTimeZone.LocalOption duplicatedTimeOpt, int[] offsets)
Returns time zone offsets from local wall time.- Overrides:
getOffsetFromLocal
in classBasicTimeZone
-
getRawOffset
public int getRawOffset()
Gets unmodified offset, NOT modified in case of daylight savings. This is the offset to add to UTC to get local time.- Specified by:
getRawOffset
in classTimeZone
- Returns:
- the unmodified offset to add to UTC to get local time.
-
inDaylightTime
public boolean inDaylightTime(java.util.Date date)
Queries if the given date is in daylight savings time in this time zone.- Specified by:
inDaylightTime
in classTimeZone
- Parameters:
date
- the given Date.- Returns:
- true if the given date is in daylight savings time, false, otherwise.
-
setRawOffset
public void setRawOffset(int offsetMillis)
Sets the base time zone offset to GMT. This is the offset to add to UTC to get local time.- Specified by:
setRawOffset
in classTimeZone
- Parameters:
offsetMillis
- the given base time zone offset to GMT.
-
useDaylightTime
public boolean useDaylightTime()
Queries if this time zone uses daylight savings time.- Specified by:
useDaylightTime
in classTimeZone
- Returns:
- true if this time zone uses daylight savings time,
false, otherwise.
Note:The default implementation of ICU TimeZone uses the tz database, which supports historic rule changes, for system time zones. With the implementation, there are time zones that used daylight savings time in the past, but no longer used currently. For example, Asia/Tokyo has never used daylight savings time since 1951. Most clients would expect that this method to return
false
for such case. The default implementation of this method returnstrue
when the time zone uses daylight savings time in the current (Gregorian) calendar year.
-
observesDaylightTime
public boolean observesDaylightTime()
Queries if this time zone is in daylight saving time or will observe daylight saving time at any future time.The default implementation in this class returns
true
ifTimeZone.useDaylightTime()
orinDaylightTime(new Date())
returnstrue
.Note: This method was added for
TimeZone
compatibility support. TheTimeZone.useDaylightTime()
method only checks the last known rule(s), therefore it may return false even the zone observes daylight saving time currently.TimeZone
addedobservesDaylightTime()
to resolve the issue. In ICU,TimeZone.useDaylightTime()
works differently. The ICU implementation checks if the zone uses daylight saving time in the current calendar year. Therefore, it will never returnfalse
if daylight saving time is currently used.ICU's TimeZone subclass implementations override this method to support the same behavior with
TimeZone.observesDaylightTime()
. UnlikeTimeZone.useDaylightTime()
, the implementation does not take past daylight saving time into account, so that this method may returnfalse
even whenTimeZone.useDaylightTime()
returnstrue
.- Overrides:
observesDaylightTime
in classTimeZone
- Returns:
true
if this time zone is in daylight saving time or will observe daylight saving time at any future time.- See Also:
TimeZone.useDaylightTime()
-
hasSameRules
public boolean hasSameRules(TimeZone other)
Returns true if this zone has the same rule and offset as another zone. That is, if this zone differs only in ID, if at all. Returns false if the other zone is null.- Overrides:
hasSameRules
in classTimeZone
- Parameters:
other
- theTimeZone
object to be compared with- Returns:
- true if the other zone is not null and is the same as this one, with the possible exception of the ID
-
getTZURL
public java.lang.String getTZURL()
Gets the RFC2445 TZURL property value. When aVTimeZone
instance was created from VTIMEZONE data, the value is set by the TZURL property value in the data. Otherwise, the initial value is null.- Returns:
- The RFC2445 TZURL property value
-
setTZURL
public void setTZURL(java.lang.String url)
Sets the RFC2445 TZURL property value.- Parameters:
url
- The TZURL property value.
-
getLastModified
public java.util.Date getLastModified()
Gets the RFC2445 LAST-MODIFIED property value. When aVTimeZone
instance was created from VTIMEZONE data, the value is set by the LAST-MODIFIED property value in the data. Otherwise, the initial value is null.- Returns:
- The Date represents the RFC2445 LAST-MODIFIED date.
-
setLastModified
public void setLastModified(java.util.Date date)
Sets the date used for RFC2445 LAST-MODIFIED property value.- Parameters:
date
- TheDate
object represents the date for RFC2445 LAST-MODIFIED property value.
-
write
public void write(java.io.Writer writer) throws java.io.IOException
Writes RFC2445 VTIMEZONE data for this time zone- Parameters:
writer
- AWriter
used for the output- Throws:
java.io.IOException
- If there were problems creating a buffered writer or writing to it.
-
write
public void write(java.io.Writer writer, long start) throws java.io.IOException
Writes RFC2445 VTIMEZONE data applicable for dates after the specified start time.- Parameters:
writer
- TheWriter
used for the outputstart
- The start time- Throws:
java.io.IOException
- If there were problems reading and writing to the writer.
-
writeSimple
public void writeSimple(java.io.Writer writer, long time) throws java.io.IOException
Writes RFC2445 VTIMEZONE data applicable near the specified date. Some common iCalendar implementations can only handle a single time zone property or a pair of standard and daylight time properties using BYDAY rule with day of week (such as BYDAY=1SUN). This method produce the VTIMEZONE data which can be handled these implementations. The rules produced by this method can be used only for calculating time zone offset around the specified date.- Parameters:
writer
- TheWriter
used for the outputtime
- The date- Throws:
java.io.IOException
- If there were problems reading or writing to the writer.
-
getNextTransition
public TimeZoneTransition getNextTransition(long base, boolean inclusive)
Returns the first time zone transition after the base time.Example code:{@.jcite com.ibm.icu.samples.util.timezone.BasicTimeZoneExample:---getNextTransitionExample}
- Specified by:
getNextTransition
in classBasicTimeZone
- Parameters:
base
- The base time.inclusive
- Whether the base time is inclusive or not.- Returns:
- A
Date
holding the first time zone transition time after the given base time, or null if no time zone transitions are available after the base time.
-
getPreviousTransition
public TimeZoneTransition getPreviousTransition(long base, boolean inclusive)
Returns the last time zone transition before the base time.Example code:{@.jcite com.ibm.icu.samples.util.timezone.BasicTimeZoneExample:---getPreviousTransitionExample}
- Specified by:
getPreviousTransition
in classBasicTimeZone
- Parameters:
base
- The base time.inclusive
- Whether the base time is inclusive or not.- Returns:
- A
Date
holding the last time zone transition time before the given base time, or null if no time zone transitions are available before the base time.
-
hasEquivalentTransitions
public boolean hasEquivalentTransitions(TimeZone other, long start, long end)
Checks if the time zone has equivalent transitions in the time range. This method returns true when all of transition times, from/to standard offsets and DST savings used by this time zone match the other in the time range.Example code:{@.jcite com.ibm.icu.samples.util.timezone.BasicTimeZoneExample:---hasEquivalentTransitionsExample}
- Overrides:
hasEquivalentTransitions
in classBasicTimeZone
- Parameters:
other
- The instance ofTimeZone
start
- The start time of the evaluated time range (inclusive)end
- The end time of the evaluated time range (inclusive)- Returns:
- true if the other time zone has the equivalent transitions in the
time range. When tz is not a
BasicTimeZone
, this method returns false.
-
getTimeZoneRules
public TimeZoneRule[] getTimeZoneRules()
Returns the array ofTimeZoneRule
which represents the rule of this time zone object. The first element in the result array will be theInitialTimeZoneRule
instance for the initial rule. The rest will be eitherAnnualTimeZoneRule
orTimeArrayTimeZoneRule
instances representing transitions.- Specified by:
getTimeZoneRules
in classBasicTimeZone
- Returns:
- The array of
TimeZoneRule
which represents this time zone.
-
getTimeZoneRules
public TimeZoneRule[] getTimeZoneRules(long start)
Returns the array ofTimeZoneRule
which represents the rule of this time zone object since the specified start time. The first element in the result array will be theInitialTimeZoneRule
instance for the initial rule. The rest will be eitherAnnualTimeZoneRule
orTimeArrayTimeZoneRule
instances representing transitions.Example code:{@.jcite com.ibm.icu.samples.util.timezone.BasicTimeZoneExample:---getTimeZoneRulesExample}
- Overrides:
getTimeZoneRules
in classBasicTimeZone
- Parameters:
start
- The start time (inclusive).- Returns:
- The array of
TimeZoneRule
which represents this time zone since the start time.
-
load
private boolean load(java.io.Reader reader)
-
parse
private boolean parse()
-
getDefaultTZName
private static java.lang.String getDefaultTZName(java.lang.String tzid, boolean isDST)
-
createRuleByRRULE
private static TimeZoneRule createRuleByRRULE(java.lang.String tzname, int rawOffset, int dstSavings, long start, java.util.List<java.lang.String> dates, int fromOffset)
-
parseRRULE
private static int[] parseRRULE(java.lang.String rrule, long[] until)
-
createRuleByRDATE
private static TimeZoneRule createRuleByRDATE(java.lang.String tzname, int rawOffset, int dstSavings, long start, java.util.List<java.lang.String> dates, int fromOffset)
-
writeZone
private void writeZone(java.io.Writer w, BasicTimeZone basictz, java.lang.String[] customProperties) throws java.io.IOException
- Throws:
java.io.IOException
-
isEquivalentDateRule
private static boolean isEquivalentDateRule(int month, int weekInMonth, int dayOfWeek, DateTimeRule dtrule)
-
writeZonePropsByTime
private static void writeZonePropsByTime(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, long time, boolean withRDATE) throws java.io.IOException
- Throws:
java.io.IOException
-
writeZonePropsByDOM
private static void writeZonePropsByDOM(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, int month, int dayOfMonth, long startTime, long untilTime) throws java.io.IOException
- Throws:
java.io.IOException
-
writeZonePropsByDOW
private static void writeZonePropsByDOW(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, int month, int weekInMonth, int dayOfWeek, long startTime, long untilTime) throws java.io.IOException
- Throws:
java.io.IOException
-
writeZonePropsByDOW_GEQ_DOM
private static void writeZonePropsByDOW_GEQ_DOM(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, int month, int dayOfMonth, int dayOfWeek, long startTime, long untilTime) throws java.io.IOException
- Throws:
java.io.IOException
-
writeZonePropsByDOW_GEQ_DOM_sub
private static void writeZonePropsByDOW_GEQ_DOM_sub(java.io.Writer writer, int month, int dayOfMonth, int dayOfWeek, int numDays, long untilTime, int fromOffset) throws java.io.IOException
- Throws:
java.io.IOException
-
writeZonePropsByDOW_LEQ_DOM
private static void writeZonePropsByDOW_LEQ_DOM(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, int month, int dayOfMonth, int dayOfWeek, long startTime, long untilTime) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFinalRule
private static void writeFinalRule(java.io.Writer writer, boolean isDst, AnnualTimeZoneRule rule, int fromRawOffset, int fromDSTSavings, long startTime) throws java.io.IOException
- Throws:
java.io.IOException
-
toWallTimeRule
private static DateTimeRule toWallTimeRule(DateTimeRule rule, int rawOffset, int dstSavings)
-
beginZoneProps
private static void beginZoneProps(java.io.Writer writer, boolean isDst, java.lang.String tzname, int fromOffset, int toOffset, long startTime) throws java.io.IOException
- Throws:
java.io.IOException
-
endZoneProps
private static void endZoneProps(java.io.Writer writer, boolean isDst) throws java.io.IOException
- Throws:
java.io.IOException
-
beginRRULE
private static void beginRRULE(java.io.Writer writer, int month) throws java.io.IOException
- Throws:
java.io.IOException
-
appendUNTIL
private static void appendUNTIL(java.io.Writer writer, java.lang.String until) throws java.io.IOException
- Throws:
java.io.IOException
-
writeHeader
private void writeHeader(java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFooter
private static void writeFooter(java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
getDateTimeString
private static java.lang.String getDateTimeString(long time)
-
getUTCDateTimeString
private static java.lang.String getUTCDateTimeString(long time)
-
parseDateTimeString
private static long parseDateTimeString(java.lang.String str, int offset)
-
offsetStrToMillis
private static int offsetStrToMillis(java.lang.String str)
-
millisToOffset
private static java.lang.String millisToOffset(int millis)
-
numToString
private static java.lang.String numToString(int num, int width)
-
isFrozen
public boolean isFrozen()
Determines whether the object has been frozen or not.
-
freeze
public TimeZone freeze()
Freezes the object.
-
cloneAsThawed
public TimeZone cloneAsThawed()
Provides for the clone operation. Any clone is initially unfrozen.- Specified by:
cloneAsThawed
in interfaceFreezable<TimeZone>
- Overrides:
cloneAsThawed
in classTimeZone
-
-