|
WebObjects 5.2 | |||||||||
| 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 acts as a proxy
for 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),
NSTimestamp,
NSTimestampFormatter, Serialized Form| Inner classes inherited from class com.webobjects.foundation.NSCoding |
NSCoding.Support |
| Field Summary | |
static String |
SystemTimeZoneDidChangeNotification
Deprecated. |
| 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()
Provides the last object given to NSTimeZone via setDefault
or setDefaultTimeZone.If no default time zone has been explicitly set,
this method returns the system time zone. |
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
or setDefaultTimeZone. |
String |
getDisplayName(boolean inDaylightSavingTime,
int aTZStyle,
Locale aLocale)
|
static NSTimeZone |
getGMT()
Returns an NSTimeZone object representing GMT. |
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()
Deprecated. |
String |
name()
Deprecated. Use getID. |
protected Object |
readResolve()
|
static void |
resetSystemTimeZone()
Deprecated. |
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 or defaultTimeZone
for the application. |
static void |
setDefaultTimeZone(NSTimeZone aTZ)
Changes the time zone provided by getDefault or defaultTimeZone
for the application. |
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 representing a fixed offset, specified in seconds, 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(java.lang.String, boolean),
timeZoneForSecondsFromGMT(int),
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(java.lang.String, boolean),
timeZoneForSecondsFromGMT(int)| Method Detail |
public String abbreviation()
"EDT" (Eastern Daylight Time).
Invokes abbreviationForTimestamp with an NSTimestamp representing the current instant.
Invoked by toString.
abbreviationDictionary(),
abbreviationForTimestamp(com.webobjects.foundation.NSTimestamp),
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(com.webobjects.foundation.NSTimestamp)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(java.lang.Object)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),
NSCodingpublic static NSTimeZone defaultTimeZone()
setDefault
or setDefaultTimeZone.If no default time zone has been explicitly set,
this method returns the system time zone.
The default time zone returned by NSTimeZone may or may not be consistent
with the default time zone returned by java.util.TimeZone.getDefault(),
setDefault(java.util.TimeZone),
setDefaultTimeZone(com.webobjects.foundation.NSTimeZone)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),
isEqualToTimeZone(com.webobjects.foundation.NSTimeZone)public static String[] getAvailableIDs()
null.knownTimeZoneNames()public static TimeZone getDefault()
setDefault
or setDefaultTimeZone. If no default time zone has been explicitly set,
this method returns the system time zone.
The default time zone returned by NSTimeZone may or may not be consistent
with the default time zone returned by java.util.TimeZone.null.defaultTimeZone(),
localTimeZone(),
setDefault(java.util.TimeZone),
systemTimeZone()
public String getDisplayName(boolean inDaylightSavingTime,
int aTZStyle,
Locale aLocale)
getDisplayName in class TimeZonepublic static NSTimeZone getGMT()
public 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
or Etc/GMT+/-hrs, like those generated by timeZoneForSecondsFromGMT.
getRawOffset in class TimeZonetimeZoneForSecondsFromGMT(int)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(java.lang.Object)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(com.webobjects.foundation.NSTimestamp)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),
isDaylightSavingTimeForTimestamp(com.webobjects.foundation.NSTimestamp)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),
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(java.lang.Object)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()
null and
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 or defaultTimeZone
for the application. The default time zone 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)
getDefault or defaultTimeZone
for the application. The default time zone is not the same as the localTimeZone,
which cannot be substituted.aTZ - the proposed default time zone.
Must be an instance of NSTimeZone.defaultTimeZone(),
setDefault(java.util.TimeZone),
localTimeZone()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.getDefault(),
localTimeZone(),
resetSystemTimeZone()public static NSTimeZone timeZoneForSecondsFromGMT(int secondsOffsetFromGMT)
secondsOffsetFromGMT corresponds to a whole hour between 12 and -12,
this method returns an existing, well-known NSTimeZone object that follows the
POSIX convention. The time zone name is "Etc/GMT<+/->
If secondsOffsetFromGMT does not correspond to a whole hour between 12 and -12,
this method creates a new time zone for the specified offset, rounded to the nearest minute.
In this case, the time zone name is consistent with the Java convention rather than the POSIX convention.
The time zone name is "GMT<+/->
secondsOffsetFromGMT - the offset from Greenwich Mean Time in seconds to use in finding an existing,
or creating an new, apolitical NSTimeZone object.timeZoneWithName(java.lang.String, boolean),
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(com.webobjects.foundation.NSTimestamp),
decodeObject(com.webobjects.foundation.NSCoder),
getID(),
knownTimeZoneNames(),
readResolve(),
systemTimeZone(),
timeZoneForSecondsFromGMT(int)
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(com.webobjects.foundation.NSCoder),
getID(),
readResolve(),
timeZoneForSecondsFromGMT(int),
timeZoneWithName(java.lang.String, boolean)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)
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||