|
WebObjects 5.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.util.TimeZone
|
+--com.webobjects.foundation.NSTimeZone
NSTimeZone defines the behavior of time zones for different geopolitical regions. Consequently, these objects have names (and abbreviations, such as "PST") for these regions. NSTimeZone objects also represent a temporal offset, either plus or minus, from Greenwich Mean Time (GMT).
NSTimeZone provides several ways to instantiate time zones.
The class also permits you to set the default time zone within your application (setDefault).
You can access this default time zone at any time with the getDefault static method.
With the localTimeZone static method, you can get a relative time zone object that decodes itself to become the default time zone for any locale in which it finds
itself.
Because NSTimeZone is a subclass of java.util.TimeZone, you can also use the java.util.TimeZone API with NSTimeZones.
WARNING: NSTimeZone is only intended to be used with NSTimestamp and NSTimestampFormatter. It produces incorrect results when used with Java's date-related classes.
Some NSTimestamp methods return date objects that are automatically bound to time zone objects. These date objects use the functionality of NSTimeZone to adjust dates for the proper locale. Unless you specify otherwise, objects returned from NSTimestamp are bound to the default time zone for the current locale.
abbreviation(),
getDefault(),
getID(),
localTimeZone(),
setDefault(java.util.TimeZone aTZ),
NSTimestamp,
NSTimestampFormatter, Serialized Form| Inner classes inherited from class com.webobjects.foundation.NSCoding |
NSCoding.Support |
| Field Summary | |
static String |
SystemTimeZoneDidChangeNotification
The name for the notification posted during any invocation of NSTimeZone's resetSystemTimeZone method. |
| Fields inherited from class java.util.TimeZone |
LONG, SHORT |
| Constructor Summary | |
|
NSTimeZone()
Required internally to implement the java.io.Serializable interface and should be considered private. |
protected |
NSTimeZone(String aName,
NSData aData)
Used internally by NSTimeZone and should be considered private. |
| Method Summary | |
String |
abbreviation()
Returns the abbreviation for the NSTimeZone at the current instant, such as "EDT" (Eastern Daylight Time). |
static NSDictionary |
abbreviationDictionary()
Provides the mappings of time zone abbreviations to time zone names. |
String |
abbreviationForTimestamp(NSTimestamp aTimestamp)
Provides the abbreviation for the NSTimeZone at the instant specified by aTimestamp. |
Class |
classForCoder()
Allows the receiver, before being encoded, to substitute a class other than its own in a coder. |
Object |
clone()
Since NSTimeZones are immutable, there's no need to make an actual clone. |
NSData |
data()
Provides an opaque object representing the behavior for this NSTimeZone. |
static Object |
decodeObject(NSCoder aDecoder)
Provided for compliance with com.webobjects.foundation.NSCoding. |
static NSTimeZone |
defaultTimeZone()
Deprecated. Use getDefault instead. |
void |
encodeWithCoder(NSCoder aCoder)
Encodes the receiver using coder. |
boolean |
equals(Object anObject)
Indicates whether this NSTimeZone has the same data as that of anObject. |
static String[] |
getAvailableIDs()
Provides a list of all of the names and abbreviations known to NSTimeZone. |
static TimeZone |
getDefault()
Provides the last object given to NSTimeZone via setDefault. |
String |
getDisplayName(boolean inDaylightSavingTime,
int aTZStyle,
Locale aLocale)
|
String |
getID()
|
int |
getOffset(int anEra,
int aYear,
int aMonth,
int aDayOfMonth,
int aDayOfWeek,
int milliseconds)
|
int |
getRawOffset()
Provides the generic difference between the NSTimeZone and Greenwich Mean Time (the offset). |
int |
hashCode()
|
boolean |
hasSameRules(TimeZone aTZ)
Invokes equals with aTZ. |
boolean |
inDaylightTime(Date aDate)
Indicates whether this NSTimeZone uses daylight savings time at aDate. |
boolean |
isDaylightSavingTime()
Indicates whether this NSTimeZone currently uses daylight savings time. |
boolean |
isDaylightSavingTimeForTimestamp(NSTimestamp aTimestamp)
Indicates whether this NSTimeZone uses daylight savings time at aTimestamp. |
boolean |
isEqualToTimeZone(NSTimeZone aTimeZone)
Deprecated. Use equals. |
static NSArray |
knownTimeZoneNames()
Provides a list of all of the names and abbreviations known to NSTimeZone. |
static NSTimeZone |
localTimeZone()
Provides an object that forwards all messages to the default time zone in the current locale for the application. |
String |
name()
Deprecated. Use getID. |
protected Object |
readResolve()
|
static void |
resetSystemTimeZone()
Clears any previously determined system time zone. |
int |
secondsFromGMT()
Indicates the difference between the NSTimeZone and Greenwich Mean Time (the offset) at the current instant. |
int |
secondsFromGMTForTimestamp(NSTimestamp aTimestamp)
Indicates the difference between the NSTimeZone and Greenwich Mean Time (the offset) at the instant specified by aTimestamp. |
static void |
setDefault(TimeZone aTZ)
Changes the time zone provided by getDefault for the application. |
static void |
setDefaultTimeZone(NSTimeZone aTZ)
Deprecated. Use setDefault instead. |
void |
setID(String anID)
Irrelevant for NSTimeZone objects, which are not mutable. |
void |
setRawOffset(int offsetMillis)
Irrelevant for NSTimeZone objects, which are not mutable. |
static NSTimeZone |
systemTimeZone()
Provides the time zone object representing the system's time zone. |
static NSTimeZone |
timeZoneForSecondsFromGMT(int secondsOffsetFromGMT)
Provides an NSTimeZone object with seconds offset from Greenwich Mean Time. |
static NSTimeZone |
timeZoneWithName(String aName,
boolean tryAbbreviation)
Provides an NSTimeZone object corresponding to aName. |
static NSTimeZone |
timeZoneWithNameAndData(String aName,
NSData aData)
Use timeZoneWithName instead of calling this method directly. |
String |
toString()
|
boolean |
useDaylightTime()
Indicates whether the NSTimeZone ever uses or has used daylight savings time. |
| Methods inherited from class java.util.TimeZone |
getAvailableIDs, getDisplayName, getDisplayName, getDisplayName, getTimeZone |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String SystemTimeZoneDidChangeNotification
resetSystemTimeZone method.resetSystemTimeZone(),
NSNotification| Constructor Detail |
public NSTimeZone()
java.io.Serializable interface and should be considered private.Use the following methods to get NSTimeZone objects:
timeZoneForSecondsFromGMTtimeZoneWithNametimeZoneWithName(String aName, boolean tryAbbreviation),
timeZoneForSecondsFromGMT(int secondsOffsetFromGMT),
Serializable
protected NSTimeZone(String aName,
NSData aData)
Use the following methods to get NSTimeZone objects:
timeZoneForSecondsFromGMTtimeZoneWithNameaName - the proposed name for the newly instantiated NSTimeZone objectaData - the proposed behavior for the newly instantiated NSTimeZone object (represented by raw binary data)timeZoneWithName(String aName, boolean tryAbbreviation),
timeZoneForSecondsFromGMT(int secondsOffsetFromGMT)| Method Detail |
public String abbreviation()
"EDT" (Eastern Daylight Time).
Invokes abbreviationForTimestamp with an NSTimestamp representing the current instant.
Invoked by toString.
abbreviationDictionary(),
abbreviationForTimestamp(NSTimestamp aTimestamp),
toString()public static NSDictionary abbreviationDictionary()
Any given name may be represented by several abbreviations. Conversely, more than one time zone may have the same abbreviation. For example, US/Pacific and Canada/Pacific both use the abbreviation "PST." In these cases, this method always chooses a single name to which to map the abbreviation.
null.getID(),
abbreviation(),
abbreviationForTimestamp(NSTimestamp aTimestamp)public String abbreviationForTimestamp(NSTimestamp aTimestamp)
aTimestamp.
Note that the abbreviation may be different at different instants.
For example, during daylight savings time, the US/Eastern time zone has an abbreviation of "EDT".
At other times, its abbreviation is "EST".
Invoked by abbreviation.
aTimestamp - the specified instantaTimestamp.
Never null.abbreviation(),
abbreviationDictionary()public Class classForCoder()
NSCodingclassForCoder in interface NSCodingcom.webobjects.foundation.NSCodingpublic Object clone()
clone in class TimeZonepublic NSData data()
equals.null.equals(Object anObject)public static Object decodeObject(NSCoder aDecoder)
com.webobjects.foundation.NSCoding.
Provides an NSTimeZone object for the decoded data.
Attempts to avoid creating duplicate objects.aDecoder - the NSCoder object used to decode this NSTimeZone objectencodeWithCoder(com.webobjects.foundation.NSCoder aCoder),
NSCodingpublic static NSTimeZone defaultTimeZone()
getDefault instead.
getDefault.getDefault()public void encodeWithCoder(NSCoder aCoder)
NSCodingcoder. Object type information along with an
object's data is stored.encodeWithCoder in interface NSCodingcom.webobjects.foundation.NSCodingcoder - an NSCoder object that will be used to encode object of classes that
implement this interfaceNSCoderpublic boolean equals(Object anObject)
data as that of anObject.
Invoked by:
hasSameRulesisEqualToTimeZoneequals in class ObjectanObject - another NSTimeZone object against which to compare this NSTimeZone.false if they have different data or if anObject is not an instance of NSTimeZone,
true otherwisedata(),
hasSameRules(java.util.TimeZone aTZ),
isEqualToTimeZone(NSTimeZone aTimeZone)public static String[] getAvailableIDs()
null.knownTimeZoneNames()public static TimeZone getDefault()
setDefault.
This is not the same thing as the localTimeZone.
Unless this behavior is changed using setDefaultTimeZone, this method returns systemTimeZone.
Invoked by defaultTimeZone.
null.defaultTimeZone(),
localTimeZone(),
setDefault(java.util.TimeZone aTZ),
systemTimeZone()
public String getDisplayName(boolean inDaylightSavingTime,
int aTZStyle,
Locale aLocale)
getDisplayName in class TimeZonepublic String getID()
getID in class TimeZone
public int getOffset(int anEra,
int aYear,
int aMonth,
int aDayOfMonth,
int aDayOfWeek,
int milliseconds)
getOffset in class TimeZonepublic int getRawOffset()
Because NSTimeZones represent geopolitical regions, many timezones don't have one, generic offset.
The offset can change over time for reasons other than daylight saving purposes.
Consequently, this method will return zero except for generic, apolitical time zones of the form GMT+/-hrs, like those generated by timeZoneForSecondsFromGMT.
getRawOffset in class TimeZonetimeZoneForSecondsFromGMT(int secondsOffsetFromGMT)public boolean hasSameRules(TimeZone aTZ)
equals with aTZ.hasSameRules in class TimeZoneaTZ - another NSTimeZone object against which to compare this NSTimeZonetrue if aTimeZone and this NSTimeZone have the same data,
false otherwisedata(),
equals(Object anObject)public int hashCode()
hashCode in class Objectpublic boolean inDaylightTime(Date aDate)
aDate.
Invokes isDaylightSavingTimeForTimestamp with an NSTimestamp representing aDate.
inDaylightTime in class TimeZoneaDate - the specified instanttrue if the NSTimeZone uses daylight savings time at the specified instant,
false otherwiseisDaylightSavingTime(),
isDaylightSavingTimeForTimestamp(NSTimestamp aTimestamp)public boolean isDaylightSavingTime()
isDaylightSavingTimeForTimestamp with an NSTimestamp representing the current instant.true if the NSTimeZone is currently using daylight savings time,
false otherwiseinDaylightTime(java.util.Date aDate),
isDaylightSavingTimeForTimestamp(NSTimestamp aTimestamp)public boolean isDaylightSavingTimeForTimestamp(NSTimestamp aTimestamp)
aTimestamp.Invoked by:
inDaylightTimeisDaylightSavingTimeaTimestamp - the specified instanttrue if the NSTimeZone uses daylight savings time at the specified instant,
false otherwiseinDaylightTime(java.util.Date aDate),
isDaylightSavingTime()public boolean isEqualToTimeZone(NSTimeZone aTimeZone)
equals.
equals with aTimeZone.aTimeZone - another NSTimeZone object against which to compare this NSTimeZonetrue if aTimeZone and this NSTimeZone have the same data,
false otherwisedata(),
equals(Object anObject)public static NSArray knownTimeZoneNames()
getAvailableIDs()public static NSTimeZone localTimeZone()
getDefault.
Never null.defaultTimeZone()public String name()
getID.
getID.getID()
protected Object readResolve()
throws ObjectStreamException
public static void resetSystemTimeZone()
systemTimeZone will redetermine the system time zone.
Also posts an NSTimeZone.SystemTimeZoneDidChangeNotification.
systemTimeZone()public int secondsFromGMT()
public int secondsFromGMTForTimestamp(NSTimestamp aTimestamp)
aTimestamp.The NSTimeZone object may change its offset from GMT at different points in the year. For example, the U.S. time zones change offsets with daylight savings time.
Because NSTimeZone objects represent geopolitical regions, offsets such as those for daylight savings time may change across different spans. For example, the organization which governs a region may abolish daylight savings time, though daylight savings time would be relevant for moments preceding the abolition.
aTimestamp - an instant in timeaTimestamppublic static void setDefault(TimeZone aTZ)
getDefault for the application.
This is not the same as the localTimeZone, which cannot be substituted.aTZ - the proposed default time zone.
Must be an instance of NSTimeZone.getDefault(),
localTimeZone()public static void setDefaultTimeZone(NSTimeZone aTZ)
setDefault instead.
setDefault.setDefault(java.util.TimeZone aTZ)public void setID(String anID)
setID in class TimeZonepublic void setRawOffset(int offsetMillis)
setRawOffset in class TimeZonepublic static NSTimeZone systemTimeZone()
localTimeZone and may be different from the time zone object returned by getDefault.
- Returns:
- the time zone currently used by the system or the GMT time
zone if the current time zone can't be determined
- See Also:
getDefault(),
localTimeZone(),
resetSystemTimeZone()
public static NSTimeZone timeZoneForSecondsFromGMT(int secondsOffsetFromGMT)
If the secondsOffsetFromGMT correspond evenly to a whole hour between 12 and -12, this method attempts to reuse an existing, well-known NSTimeZone objects for that
offset.
Otherwise, creates a new NSTimeZone instance for the specified offset.
These time zones are always apolitical. They never use daylight savings time, and their offset is constant.
The name and abbreviation for these time zones do NOT follow the POSIX convention of minutes-west.
secondsOffsetFromGMT - the specified offset in seconds to use in creating a new or finding an existing, apolitical NSTimeZone objectnull if secondsOffsetFromGMT correspond evenly to hours and the corresponding NSTimeZone object can't be found.timeZoneWithName(String aName, boolean tryAbbreviation),
getID()
public static NSTimeZone timeZoneWithName(String aName,
boolean tryAbbreviation)
aName.
Avoids creating duplicate NSTimeZone objects as much as possible.
This method is the recommended way for you to create or retrieve NSTimeZone objects.Invoked by:
decodeObjectreadResolvesystemTimeZonetimeZoneForSecondsFromGMTaName - the name or abbreviation used to search for an existing NSTimeZone object.
Should never be null.tryAbbreviation - true to match aName against the abbreviationDictionary,
false otherwiseaName,
null if there is no matchabbreviation(),
abbreviationDictionary(),
abbreviationForTimestamp(NSTimestamp aTimestamp),
decodeObject(NSCoder aDecoder),
getID(),
knownTimeZoneNames(),
readResolve(),
systemTimeZone(),
timeZoneForSecondsFromGMT(int secondsOffsetFromGMT)
public static NSTimeZone timeZoneWithNameAndData(String aName,
NSData aData)
timeZoneWithName instead of calling this method directly.Invoked by:
decodeObjectreadResolvetimeZoneForSecondsFromGMTaName - the proposed name of the new NSTimeZone object.
Should never be null.
May be coerced into another name, if there's a preferred name for the time zone identified.aData - the proposed behavior (represented by raw binary data) for the new NSTimeZone object.
Should never be null.data(),
decodeObject(NSCoder aDecoder),
getID(),
readResolve(),
timeZoneForSecondsFromGMT(int secondsOffsetFromGMT),
timeZoneWithName(String aName, boolean tryAbbreviation)public String toString()
toString in class Objectpublic boolean useDaylightTime()
true for objects that represent geopolitical regions.useDaylightTime in class TimeZonetrue if the time zone ever uses or has used daylight savings time,
false otherwisetimeZoneForSecondsFromGMT(int secondsOffsetFromGMT)
|
Last updated Thu Jan 10 18:10:21 PST 2002. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||