PATH  Documentation > Mac OS X > Foundation Reference: Java



Table of Contents

NSTimeZone


Inherits from:
NSObject
Package:
com.apple.yellow.foundation


Class Description


NSTimeZone is an abstract class that 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.

Some NSGregorianDate 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 NSGregorianDate are bound to the default time zone for the current locale.




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
abbreviationForDate
name
secondsFromGMT
secondsFromGMTForDate
isDaylightSavingTime
isDaylightSavingTimeForDate
data
Comparing time zones
equals
isEqualToTimeZone


Constructors



NSTimeZone

public NSTimeZone()

Description forthcoming.

public NSTimeZone(int seconds)

Returns a time zone object with seconds offset from Greenwich Mean Time. The name of the new time zone is GMT +/- the offset, in hours and minutes.

public NSTimeZone( String aTimeZoneName, NSData data)

Returns the time zone with the name aTimeZoneName whose data has been initialized using the contents of data. You should not call this method directly-use the constructor that takes a time zone name and a flag.

public NSTimeZone( String aTimeZoneName, boolean isAbbrev)

Returns the time zone object identified by aTimeZoneName. If isAbbrev is false, this constructor searches the time zone information directory a name that matches aTimeZoneName. If isAbbrev is true, this constructor first tries to resolve aTimeZoneName to a name using the abbreviation dictionary and then searches the time zone information directory a name that matches aTimeZoneName. In either case, this constructor returns null if it doesn't find a match for aTimeZoneName.




Static Methods



abbreviationDictionary

public static NSDictionary abbreviationDictionary()

Returns a dictionary holding the mappings of time zone abbreviations to time zone names.

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.



defaultTimeZone

public static NSTimeZone defaultTimeZone()

Returns the default time zone set for your application. If no default time zone has been set, this method invokes systemTimeZone and returns the system time zone.

See Also: localTimeZone, setDefaultTimeZone, systemTimeZone



knownTimeZoneNames

public static NSArray knownTimeZoneNames()

Returns an array of strings listing the names of all the time zones known to the system.

localTimeZone

public static NSTimeZone localTimeZone()

Returns an object that forwards all messages to the default time zone for your application. This behavior is particularly useful for NSGregorianDate objects that are archived or sent as Distributed Objects and may be interpreted in different locales.

See Also: defaultTimeZone, setDefaultTimeZone



resetSystemTimeZone

public static void resetSystemTimeZone()

Clears the previously determined system time zone, if any. Subsequent calls to systemTimeZone will attempt to redetermine the system time zone.

setDefaultTimeZone

public static void setDefaultTimeZone(NSTimeZone aTimeZone)

Sets the time zone appropriate for your application. There can be only one default time zone, so by setting a new default time zone, you lose the previous one.

See Also: defaultTimeZone, localTimeZone



systemTimeZone

public static NSTimeZone systemTimeZone()

Returns the time zone currently used by the system. If it can't figure out the current time zone, returns the GMT time zone.


Instance Methods



abbreviation

public String abbreviation()

Returns the abbreviation for the time zone, such as "EDT" (Eastern Daylight Time). Invokes abbreviationForDate with the current date as the argument.

abbreviationForDate

public String abbreviationForDate(NSDate aDate)

Returns the abbreviation for the time zone object at the specified date. Note that the abbreviation may be different at different dates. For example, during Daylight Savings Time the US/Eastern time zone has an abbreviation of "EDT." At other times, its abbreviation is "EST."

data

public NSData data()

Returns the data that stores the information used by the time zone. This data should be treated as an opaque object.

equals

public boolean equals(Object anObject)

Description forthcoming.

hashCode

public int hashCode()

Description forthcoming.

isDaylightSavingTime

public boolean isDaylightSavingTime()

Returns true if the time zone is currently using Daylight Savings Time. This method invokes isDaylightSavingTimeForDate with the current date as the argument.

isDaylightSavingTimeForDate

public boolean isDaylightSavingTimeForDate(NSDate aDate)

Returns true if the time zone uses Daylight Savings Time at aDate.

isEqualToTimeZone

public boolean isEqualToTimeZone(NSTimeZone aTimeZone)

Returns true if aTimeZone and the receiving time zone have the same name and data.

name

public String name()

Returns the geopolitical region name that identifies the time zone.

secondsFromGMT

public int secondsFromGMT()

Returns the current difference in seconds between the time zone and Greenwich Mean Time.

secondsFromGMTForDate

public int secondsFromGMTForDate(NSDate aDate)

Returns the difference in seconds between the time zone and Greenwich Mean Time at aDate. This may be different from the current difference if the time zone changes its offset from GMT at different points in the year-for example, the U.S. time zones change with daylight savings time.

toString

public String toString()

Description forthcoming.


Table of Contents