jMobileCore toolkit

com.jmobilecore.support
Class TimeZone

java.lang.Object
  extended by com.jmobilecore.support.TimeZone

public class TimeZone
extends java.lang.Object

The TimeZone represents a time zone offset and daylight savings.

Author:
Greg Gridin

Field Summary
 boolean daylight
          The current TimeZone daylight setting
protected static TimeZone defTimeZone
          The default timezone (GMT)
protected  java.lang.String id
          The current TimeZone id
protected static java.lang.String[] ids
          The list of available timezones
protected  int offset
          The current TimeZone offset
protected static int[] offsets
          Timezone's offsets
 
Constructor Summary
protected TimeZone(java.lang.String id, int offset)
          Constructor for the TimeZone class
 
Method Summary
static java.lang.String[] getAvailableIDs()
          Gets all the available IDs supported.
static int[] getAvailableOffsets()
          Gets all the available offsets supported.
static TimeZone getDefault()
          Gets the default TimeZone.
 java.lang.String getID()
          Gets the ID of this time zone.
 int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)
          Gets the time zone offset, for current date, modified in case of daylight savings.
 int getRawOffset()
          Returns the amount of time in milliseconds to add to UTC to get standard time in this time zone.
static TimeZone getTimeZone(java.lang.String timezone)
          Gets the TimeZone for the given ID.
 boolean useDaylightTime()
          Gets if this time zone uses daylight savings time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

daylight

public boolean daylight
The current TimeZone daylight setting


defTimeZone

protected static final TimeZone defTimeZone
The default timezone (GMT)

See Also:
getDefault()

id

protected java.lang.String id
The current TimeZone id


ids

protected static final java.lang.String[] ids
The list of available timezones


offset

protected int offset
The current TimeZone offset


offsets

protected static final int[] offsets
Timezone's offsets

Constructor Detail

TimeZone

protected TimeZone(java.lang.String id,
                   int offset)
Constructor for the TimeZone class

Parameters:
id - the TimeZone id
offset - the TimeZone offset
Method Detail

getAvailableIDs

public static java.lang.String[] getAvailableIDs()
Gets all the available IDs supported.

Returns:
an array of String IDs.

getAvailableOffsets

public static int[] getAvailableOffsets()
Gets all the available offsets supported.

Returns:
an array of offsets.
See Also:
getAvailableIDs()

getDefault

public static TimeZone getDefault()
Gets the default TimeZone.

See Also:
defTimeZone

getID

public java.lang.String getID()
Gets the ID of this time zone.

Returns:
the ID of this time zone.

getOffset

public int getOffset(int era,
                     int year,
                     int month,
                     int day,
                     int dayOfWeek,
                     int millis)
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.

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.
millis - the milliseconds in day in standard local time.
Returns:
the offset in milliseconds to add to GMT to get local time.

getRawOffset

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

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

getTimeZone

public static TimeZone getTimeZone(java.lang.String timezone)
Gets the TimeZone for the given ID.

Parameters:
timezone - the ID for a TimeZone
Returns:
the specified TimeZone, or the GMT zone if the given timezone id cannot be understood
See Also:
ids

useDaylightTime

public boolean useDaylightTime()
Gets if this time zone uses daylight savings time.

Returns:
true if this time zone uses daylight savings time, false, otherwise.

jMobileCore toolkit