PATH |
NSTimeZone
- Inherits from:
- java.util.TimeZone : Object
- Implements:
- Cloneable
- Serializable
- NSCoding
- Package:
- com.webobjects.foundation
Class Description
NSTimeZone defines the behavior of time zone objects. Time zone objects represent geopolitical regions. Consequently, these objects have names for these regions. Time zone objects also represent a temporal offset, either plus or minus, from Greenwich Mean Time (GMT) and an abbreviation (such as "PST").
NSTimeZone provides several constructors to get time zone objects. The class also permits you to set the default time zone within your application ( setDefaultTimeZone). You can access this default time zone at any time with the defaultTimeZone static method, and 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.
Interfaces Implemented
- Cloneable
- clone
- java.io.Serializable
- NSCoding
- decodeObject
- classForCoder
- encodeWithCoder
Method Types
- Constructors
- NSTimeZone
- Getting the default time zone
- localTimeZone
- defaultTimeZone
- setDefaultTimeZone
- resetSystemTimeZone
- Getting time zone information
- abbreviationDictionary
- knownTimeZoneNames
- Getting information about a specific time zone
- abbreviation
- abbreviationForTimestamp
- name
- secondsFromGMT
- secondsFromGMTForTimestamp
- isDaylightSavingTime
- isDaylightSavingTimeForTimestamp
- data
- Comparing time zones
- equals
- isEqualToTimeZone
- Instance methods inherited from java.util.TimeZone
- getAvailableIDs
- getDefault
- getDisplayName
- getID
- getOffset
- getRawOffset
- hasSameRules
- inDaylightTime
- setDefault
- setID
- setRawOffset
- useDaylightTime
Constructors
NSTimeZone
public NSTimeZone()
protected NSTimeZone( String aTimeZoneName, NSData data)
This constructor is used internally by NSTimeZone and should be considered private. Use the static factory methods to create time zones.
Static Methods
abbreviationDictionary
public static NSDictionary abbreviationDictionary()
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 abbreviationDictionary chooses a single name to map the abbreviation to.
decodeObject
public static Object decodeObject(NSCoder coder)
See Also: NSCoding Interface Description
defaultTimeZone
public static synchronized NSTimeZone defaultTimeZone()
See Also: localTimeZone, setDefaultTimeZone, systemTimeZone
getAvailableIDs
public static String[] getAvailableIDs()
getDefault
public static java.util.TimeZone getDefault()
knownTimeZoneNames
public static NSArray knownTimeZoneNames()
localTimeZone
public static NSTimeZone localTimeZone()
See Also: defaultTimeZone, setDefaultTimeZone
resetSystemTimeZone
public static synchronized void resetSystemTimeZone()
setDefault
public static synchronized void setDefault(java.util.TimeZone zone)
setDefaultTimeZone
public static synchronized void setDefaultTimeZone(NSTimeZone aTimeZone)
See Also: defaultTimeZone, localTimeZone
systemTimeZone
public static synchronized NSTimeZone systemTimeZone()
timeZoneForSecondsFromGMT
public static synchronized NSTimeZone timeZoneForSecondsFromGMT(int seconds)
See Also: timeZoneWithName
timeZoneWithName
public static synchronized NSTimeZone timeZoneWithName( String aTimeZoneName, boolean trybbreviation)
false
, this method searches the time zone information directory for matching names. If tryAbbreviation is true
, this method attempts to resolve the abbreviation to a name using the abbreviation dictionary. Returns null
if there is no match on the name.
See Also: timeZoneForSecondsFromGMT, knownTimeZoneNames
timeZoneWithNameAndData
public static synchronized NSTimeZone timeZoneWithNameAndData( String aTimeZoneName, NSData data)
Instance Methods
abbreviation
public String abbreviation()
abbreviationForTimestamp
public String abbreviationForTimestamp(NSTimestamp aTimestamp)
classForCoder
public Class classForCoder()
See Also: classForCoder (NSCoding)
clone
public Object clone()
data
public NSData data()
encodeWithCoder
public void encodeWithCoder(NSCoder coder)
equals
public boolean equals(Object anObject)
true
if anObject is an NSTimeZone and its contents are equal to the receiver's or false
otherwise. If you know that anObject is an NSTimestamp, use the more efficient method isEqualToTimeZone instead.
getDisplayName
public String getDisplayName( boolean daylight, int style, java.util.Locale locale)
getID
public String getID()
getOffset
public int getOffset( int era, int year, int month, int day, int dayOfWeek, int milliseconds)
getRawOffset
public int getRawOffset()
hashCode
public synchronized int hashCode()
hasSameRules
public boolean hasSameRules(java.util.TimeZone other)
true
if other is the same as the receiver (as determined by equals.).
inDaylightTime
public boolean inDaylightTime(java.util.Date date)
isDaylightSavingTime
public boolean isDaylightSavingTime()
true
if the time zone is currently using Daylight Savings Time. This method invokes isDaylightSavingTimeForTimestamp with the current date as the argument.
isDaylightSavingTimeForTimestamp
public boolean isDaylightSavingTimeForTimestamp(NSTimestamp aTimestamp)
true
if the time zone uses Daylight Savings Time at the date specified by aTimestamp.
isEqualToTimeZone
public boolean isEqualToTimeZone(NSTimeZone aTimeZone)
true
if aTimeZone and the receiving time zone have the same name and data.
name
public String name()
readExternal
public void readExternal(java.io.ObjectInput input) throws java.io.IOException,ClassNotFoundException
readResolve
public Object readResolve() throws java.io.ObjectStreamException
secondsFromGMT
public int secondsFromGMT()
secondsFromGMTForTimestamp
public int secondsFromGMTForTimestamp(NSTimestamp aTimestamp)
setID
public void setID(String ID)
setRawOffset
public void setRawOffset(int offsetMillis)
toString
public String toString()
useDaylightTime
public boolean useDaylightTime()
writeExternal
public void writeExternal( java.io.ObjectOutput output) throws java.io.IOException
Notifications
SystemTimeZoneDidChangeNotification
public static final String
SystemTimeZoneDidChangeNotification
;
© 2001 Apple Computer, Inc. (Last Published April 17, 2001)