|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.joda.time.DateTimeZone
DateTimeZone represents a time zone.
A time zone is a system of rules to convert time from one geographic location to another. For example, Paris, France in one hour ahead of London, England. Thus when it is 10:00 in London, it is 11:00 in Paris.
All time zone rules are expressed, for historical reasons, relative to Greenwich, London. Local time in Greenwich is referred to as Greenwich Mean Time (GMT). This is similar, but not precisely identical, to Universal Coordinated Time, or UTC. This library only uses the term UTC.
Using this system, Pacific Time, USA is expressed as UTC-08:00, or UTC-07:00 in the summer. The offset -08:00 indicates that Pacific Time is obtained from UTC by adding -08:00, that is, by subtracting 8 hours.
The offset differs in the summer because of daylight saving time, or DST. The folowing definitions of time are generally used:
Unlike the Java TimeZone class, DateTimeZone is immutable. It also only supports long format time zone ids. Thus EST and ECT are not accepted. However, the factory that accepts a TimeZone will attempt to convert from the old short id to a suitable long id.
| Field Summary | |
static DateTimeZone |
UTC
The UTC time zone |
| Constructor Summary | |
DateTimeZone(java.lang.String id)
|
|
| Method Summary | |
abstract boolean |
equals(java.lang.Object obj)
Compare this datetime zone with another. |
static java.util.Set |
getAvailableIDs()
Gets all the available IDs supported. |
static DateTimeZone |
getDefault()
Gets the default time zone. |
java.lang.String |
getID()
Gets the ID of this datetime zone. |
static DateTimeZone |
getInstance(java.lang.String id)
Get the time zone by id. |
static DateTimeZone |
getInstance(java.util.TimeZone zone)
Get the time zone by Java TimeZone. |
java.lang.String |
getName(long millis)
Gets the long name of this datetime zone suitable for display using the default locale. |
java.lang.String |
getName(long millis,
java.util.Locale locale)
Gets the long name of this datetime zone suitable for display using the specified locale. |
abstract java.lang.String |
getNameKey(long millis)
Returns a non-localized name that is unique to this time zone. |
static NameProvider |
getNameProvider()
|
abstract int |
getOffset(long millis)
Gets the millisecond offset to add to UTC to get local time. |
int |
getOffset(ReadableInstant instant)
Gets the millisecond offset to add to UTC to get local time. |
int |
getOffsetFromLocal(long millisLocal)
Gets the millisecond offset to subtract from local time to get UTC time. |
static Provider |
getProvider()
|
java.lang.String |
getShortName(long millis)
Gets the short name of this datetime zone suitable for display using the default locale. |
java.lang.String |
getShortName(long millis,
java.util.Locale locale)
Gets the short name of this datetime zone suitable for display using the specified locale. |
abstract int |
getStandardOffset(long millis)
Gets the standard millisecond offset to add to UTC to get local time, when standard time is in effect. |
int |
hashCode()
Gets a hash code compatable with equals. |
abstract long |
nextTransition(long millis)
Advances the given instant to where the time zone offset or name changes. |
abstract long |
previousTransition(long millis)
Retreats the given instant to where the time zone offset or name changes. |
static void |
setDefault(DateTimeZone zone)
Sets the default time zone. |
static void |
setNameProvider(NameProvider nameProvider)
|
static void |
setProvider(Provider provider)
|
java.lang.String |
toString()
Gets the datetime zone as a string, which is simply its ID. |
java.util.TimeZone |
toTimeZone()
Get the datetime zone as a TimeZone. |
protected java.lang.Object |
writeReplace()
By default, when DateTimeZones are serialized, only a "stub" object referring to the id is written out. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final DateTimeZone UTC
| Constructor Detail |
public DateTimeZone(java.lang.String id)
| Method Detail |
public static DateTimeZone getDefault()
public static void setDefault(DateTimeZone zone)
throws java.lang.SecurityException
zone - the default datetime zone object, must not be null
java.lang.IllegalArgumentException - if the zone is null
java.lang.SecurityException
public static DateTimeZone getInstance(java.lang.String id)
throws java.lang.IllegalArgumentException
The time zone id may be one of those returned by getAvailableIDs. Short
ids, as accepted by TimeZone, are not accepted. All
IDs must be specified in the long format. The exception is UTC, which is
an acceptable id.
Alternatively a locale independent, fixed offset, datetime zone can
be specified. The form [+-]hh:mm can be used.
id - the ID of the datetime zone
java.lang.IllegalArgumentException - if the ID is null or not recognisedpublic static DateTimeZone getInstance(java.util.TimeZone zone)
DateTimeZone only accepts a subset of the IDs from TimeZone. The excluded IDs are the short three letter form (except UTC). This method will attempt to convert between time zones created using the short IDs and the full version.
zone - the zone to convert
java.lang.IllegalArgumentException - if the zone is null or not recognisedpublic static java.util.Set getAvailableIDs()
public static Provider getProvider()
public static void setProvider(Provider provider)
throws java.lang.SecurityException
java.lang.SecurityExceptionpublic static NameProvider getNameProvider()
public static void setNameProvider(NameProvider nameProvider)
throws java.lang.SecurityException
java.lang.SecurityExceptionpublic final java.lang.String getID()
public abstract java.lang.String getNameKey(long millis)
millis - milliseconds from 1970-01-01T00:00:00Z to get the name for
public final java.lang.String getShortName(long millis)
If the name is not available for the locale, then this method returns a
string in the format [+-]hh:mm.
millis - milliseconds from 1970-01-01T00:00:00Z to get the name for
public java.lang.String getShortName(long millis,
java.util.Locale locale)
If the name is not available for the locale, then this method returns a
string in the format [+-]hh:mm.
millis - milliseconds from 1970-01-01T00:00:00Z to get the name for
public final java.lang.String getName(long millis)
If the name is not available for the locale, then this method returns a
string in the format [+-]hh:mm.
millis - milliseconds from 1970-01-01T00:00:00Z to get the name for
public java.lang.String getName(long millis,
java.util.Locale locale)
If the name is not available for the locale, then this method returns a
string in the format [+-]hh:mm.
millis - milliseconds from 1970-01-01T00:00:00Z to get the name for
public abstract int getOffset(long millis)
millis - milliseconds from 1970-01-01T00:00:00Z to get the offset for
public final int getOffset(ReadableInstant instant)
instant - instant to get the offset for
java.lang.IllegalArgumentException - if the instant is nullpublic abstract int getStandardOffset(long millis)
millis - milliseconds from 1970-01-01T00:00:00Z to get the offset for
public int getOffsetFromLocal(long millisLocal)
millisLocal == millisUTC + getOffset(millisUTC) millisUTC == millisLocal - getOffsetFromLocal(millisLocal)Note: After calculating millisLocal, some error may be introduced. At offset transitions (due to DST or other historical changes), ranges of local times may map to different UTC times.
millisLocal - the millisecond instant, relative to this time zone, to
get the offset for
public abstract long nextTransition(long millis)
millis - milliseconds from 1970-01-01T00:00:00Z
public abstract long previousTransition(long millis)
millis - milliseconds from 1970-01-01T00:00:00Z
public java.util.TimeZone toTimeZone()
TimeZone.
public abstract boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
protected java.lang.Object writeReplace()
throws java.io.ObjectStreamException
java.io.ObjectStreamException
|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||