다음을 통해 공유


TimeZone Class

Definition

TimeZone represents a time zone offset, and also figures out daylight savings.

[Android.Runtime.Register("java/util/TimeZone", DoNotGenerateAcw=true)]
public abstract class TimeZone : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable, Java.Lang.ICloneable
[<Android.Runtime.Register("java/util/TimeZone", DoNotGenerateAcw=true)>]
type TimeZone = class
    inherit Object
    interface ISerializable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface ICloneable
Inheritance
TimeZone
Derived
Attributes
Implements

Remarks

TimeZone represents a time zone offset, and also figures out daylight savings.

Typically, you get a TimeZone using getDefault which creates a TimeZone based on the time zone where the program is running. For example, for a program running in Japan, getDefault creates a TimeZone object based on Japanese Standard Time.

You can also get a TimeZone using getTimeZone along with a time zone ID. For instance, the time zone ID for the U.S. Pacific Time zone is "America/Los_Angeles". So, you can get a U.S. Pacific Time TimeZone object with: <blockquote>

TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");

</blockquote> You can use the getAvailableIDs method to iterate through all the supported time zone IDs. You can then choose a supported ID to get a TimeZone. If the time zone you want is not represented by one of the supported IDs, then a custom time zone ID can be specified to produce a TimeZone. The syntax of a custom time zone ID is:

<blockquote>

<a id="CustomID"><i>CustomID:</i></a>
                    {@code GMT} <i>Sign</i> <i>Hours</i> {@code :} <i>Minutes</i>
                    {@code GMT} <i>Sign</i> <i>Hours</i> <i>Minutes</i>
                    {@code GMT} <i>Sign</i> <i>Hours</i>
<i>Sign:</i> one of
                    {@code + -}
<i>Hours:</i>
<i>Digit</i>
<i>Digit</i> <i>Digit</i>
<i>Minutes:</i>
<i>Digit</i> <i>Digit</i>
<i>Digit:</i> one of
                    {@code 0 1 2 3 4 5 6 7 8 9}

</blockquote>

Hours must be between 0 to 23 and Minutes must be between 00 to 59. For example, "GMT+10" and "GMT+0010" mean ten hours and ten minutes ahead of GMT, respectively.

The format is locale independent and digits must be taken from the Basic Latin block of the Unicode standard. No daylight saving time transition schedule can be specified with a custom time zone ID. If the specified string doesn't match the syntax, "GMT" is used.

When creating a TimeZone, the specified custom time zone ID is normalized in the following syntax: <blockquote>

<a id="NormalizedCustomID"><i>NormalizedCustomID:</i></a>
                    {@code GMT} <i>Sign</i> <i>TwoDigitHours</i> {@code :} <i>Minutes</i>
<i>Sign:</i> one of
                    {@code + -}
<i>TwoDigitHours:</i>
<i>Digit</i> <i>Digit</i>
<i>Minutes:</i>
<i>Digit</i> <i>Digit</i>
<i>Digit:</i> one of
                    {@code 0 1 2 3 4 5 6 7 8 9}

</blockquote> For example, TimeZone.getTimeZone("GMT-8").getID() returns "GMT-08:00".

<h2>Three-letter time zone IDs</h2>

For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such as "PST", "CTT", "AST") are also supported. However, <strong>their use is deprecated</strong> because the same abbreviation is often used for multiple time zones (for example, "CST" could be U.S. "Central Standard Time" and "China Standard Time"), and the Java platform can then only recognize one of them.

Added in 1.1.

Java documentation for java.util.TimeZone.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

TimeZone()

Sole constructor.

TimeZone(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

Long
Obsolete.

A style specifier for getDisplayName() indicating a long name, such as "Pacific Standard Time.

Short
Obsolete.

A style specifier for getDisplayName() indicating a short name, such as "PST.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Default

Gets the default TimeZone for this host. -or- Sets the TimeZone that is returned by the getDefault method.

DisplayName

Returns a long standard time name of this TimeZone suitable for presentation to the user in the default locale.

DSTSavings

Returns the amount of time to be added to local standard time to get local wall clock time.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
ID

Gets the ID of this time zone. -or- Sets the time zone ID.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
RawOffset

Returns the offset in milliseconds from UTC of this time zone's standard time.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Clone()

Creates a copy of this TimeZone.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetAvailableIDs()

Gets all the available IDs supported.

GetAvailableIDs(Int32)

Gets the available IDs according to the given time zone offset in milliseconds.

GetDisplayName(Boolean, TimeZoneStyle, Locale)

Returns the #SHORT short or #LONG long name of this time zone with either standard or daylight time, as written in locale.

GetDisplayName(Boolean, TimeZoneStyle)

Returns a name in the specified style of this TimeZone suitable for presentation to the user in the default locale.

GetDisplayName(Locale)

Returns a long standard time name of this TimeZone suitable for presentation to the user in the specified locale.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetOffset(Int32, Int32, Int32, Int32, Int32, Int32)

Gets the time zone offset, for current date, modified in case of daylight savings.

GetOffset(Int64)

Returns the offset of this time zone from UTC at the specified date.

GetTimeZone(String)

Gets the TimeZone for the given ID.

GetTimeZone(ZoneId)

Gets the TimeZone for the given zoneId.

HasSameRules(TimeZone)

Returns true if this zone has the same rule and offset as another zone.

InDaylightTime(Date)

Queries if the given date is in Daylight Saving Time in this time zone.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
ObservesDaylightTime()

Returns true if this TimeZone is currently in Daylight Saving Time, or if a transition from Standard Time to Daylight Saving Time occurs at any future time.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
ToZoneId()

Converts this TimeZone object to a ZoneId.

UnregisterFromRuntime() (Inherited from Object)
UseDaylightTime()

Queries if this TimeZone uses Daylight Saving Time.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to