- Inherits from:
- NSObject
- Package:
- com.apple.yellow.foundation
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.
- 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
public NSTimeZone()
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.
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.
public static NSTimeZone defaultTimeZone()
See Also: localTimeZone, setDefaultTimeZone, systemTimeZone
public static NSArray knownTimeZoneNames()
public static NSTimeZone localTimeZone()
See Also: defaultTimeZone, setDefaultTimeZone
public static void resetSystemTimeZone()
public static void setDefaultTimeZone(NSTimeZone aTimeZone)
See Also: defaultTimeZone, localTimeZone
public static NSTimeZone systemTimeZone()
public String abbreviation()
public String abbreviationForDate(NSDate aDate)
public NSData data()
public boolean equals(Object anObject)
public int hashCode()
public boolean isDaylightSavingTime()
true
if
the time zone is currently using Daylight Savings Time. This
method invokes isDaylightSavingTimeForDate with
the current date as the argument.public boolean isDaylightSavingTimeForDate(NSDate aDate)
true
if
the time zone uses Daylight Savings Time at aDate.public boolean isEqualToTimeZone(NSTimeZone aTimeZone)
true
if aTimeZone and
the receiving time zone have the same name and data.public String name()
public int secondsFromGMT()
public int secondsFromGMTForDate(NSDate aDate)
public String toString()