Sdílet prostřednictvím


ZonedDateTime Class

Definition

A date-time with a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00 Europe/Paris.

[Android.Runtime.Register("java/time/ZonedDateTime", ApiSince=26, DoNotGenerateAcw=true)]
public sealed class ZonedDateTime : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable, Java.Time.Chrono.IChronoZonedDateTime
[<Android.Runtime.Register("java/time/ZonedDateTime", ApiSince=26, DoNotGenerateAcw=true)>]
type ZonedDateTime = class
    inherit Object
    interface ISerializable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IChronoZonedDateTime
    interface IComparable
    interface ITemporal
    interface ITemporalAccessor
Inheritance
ZonedDateTime
Attributes
Implements

Remarks

A date-time with a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00 Europe/Paris.

ZonedDateTime is an immutable representation of a date-time with a time-zone. This class stores all date and time fields, to a precision of nanoseconds, and a time-zone, with a zone offset used to handle ambiguous local date-times. For example, the value "2nd October 2007 at 13:45.30.123456789 +02:00 in the Europe/Paris time-zone" can be stored in a ZonedDateTime.

This class handles conversion from the local time-line of LocalDateTime to the instant time-line of Instant. The difference between the two time-lines is the offset from UTC/Greenwich, represented by a ZoneOffset.

Converting between the two time-lines involves calculating the offset using the ZoneRules rules accessed from the ZoneId. Obtaining the offset for an instant is simple, as there is exactly one valid offset for each instant. By contrast, obtaining the offset for a local date-time is not straightforward. There are three cases: <ul> <li>Normal, with one valid offset. For the vast majority of the year, the normal case applies, where there is a single valid offset for the local date-time.</li> <li>Gap, with zero valid offsets. This is when clocks jump forward typically due to the spring daylight savings change from "winter" to "summer". In a gap there are local date-time values with no valid offset.</li> <li>Overlap, with two valid offsets. This is when clocks are set back typically due to the autumn daylight savings change from "summer" to "winter". In an overlap there are local date-time values with two valid offsets.</li> </ul>

Any method that converts directly or implicitly from a local date-time to an instant by obtaining the offset has the potential to be complicated.

For Gaps, the general strategy is that if the local date-time falls in the middle of a Gap, then the resulting zoned date-time will have a local date-time shifted forwards by the length of the Gap, resulting in a date-time in the later offset, typically "summer" time.

For Overlaps, the general strategy is that if the local date-time falls in the middle of an Overlap, then the previous offset will be retained. If there is no previous offset, or the previous offset is invalid, then the earlier offset is used, typically "summer" time.. Two additional methods, #withEarlierOffsetAtOverlap() and #withLaterOffsetAtOverlap(), help manage the case of an overlap.

In terms of design, this class should be viewed primarily as the combination of a LocalDateTime and a ZoneId. The ZoneOffset is a vital, but secondary, piece of information, used to ensure that the class represents an instant, especially during a daylight savings overlap.

Added in 1.8.

Java documentation for java.time.ZonedDateTime.

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.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
DayOfMonth

Gets the day-of-month field.

DayOfWeek
DayOfYear

Gets the day-of-year field.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
Hour

Gets the hour-of-day field.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Minute

Gets the minute-of-hour field.

Month
MonthValue

Gets the month-of-year field from 1 to 12.

Nano

Gets the nano-of-second field.

Offset
PeerReference (Inherited from Object)
Second

Gets the second-of-minute field.

ThresholdClass

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

(Inherited from Object)
ThresholdType

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

(Inherited from Object)
Year

Gets the year field.

Zone

Methods

Clone()

Creates and returns a copy of this object.

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

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

(Inherited from Object)
Format(DateTimeFormatter)
From(ITemporalAccessor)
Get(ITemporalField)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetLong(ITemporalField)
IsSupported(ITemporalField)
IsSupported(ITemporalUnit)
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)
Minus(Int64, ITemporalUnit)
Minus(ITemporalAmount)
MinusDays(Int64)
MinusHours(Int64)
MinusMinutes(Int64)
MinusMonths(Int64)
MinusNanos(Int64)
MinusSeconds(Int64)
MinusWeeks(Int64)
MinusYears(Int64)
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)
Now()
Now(Clock)
Now(ZoneId)
Of(Int32, Int32, Int32, Int32, Int32, Int32, Int32, ZoneId)
Of(LocalDate, LocalTime, ZoneId)
Of(LocalDateTime, ZoneId)
OfInstant(Instant, ZoneId)
OfInstant(LocalDateTime, ZoneOffset, ZoneId)
OfLocal(LocalDateTime, ZoneId, ZoneOffset)
OfStrict(LocalDateTime, ZoneOffset, ZoneId)
Parse(ICharSequence, DateTimeFormatter)
Parse(ICharSequence)
Parse(String, DateTimeFormatter)
Parse(String)
Plus(Int64, ITemporalUnit)
Plus(ITemporalAmount)
PlusDays(Int64)
PlusHours(Int64)
PlusMinutes(Int64)
PlusMonths(Int64)
PlusNanos(Int64)
PlusSeconds(Int64)
PlusWeeks(Int64)
PlusYears(Int64)
Query(ITemporalQuery)
Range(ITemporalField)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToLocalDate()
ToLocalDateTime()
ToLocalTime()
ToOffsetDateTime()
ToString()

Returns a string representation of the object.

(Inherited from Object)
TruncatedTo(ITemporalUnit)
UnregisterFromRuntime() (Inherited from Object)
Until(ITemporal, ITemporalUnit)
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)
With(ITemporalAdjuster)
With(ITemporalField, Int64)
WithDayOfMonth(Int32)
WithDayOfYear(Int32)
WithEarlierOffsetAtOverlap()
WithFixedOffsetZone()
WithHour(Int32)
WithLaterOffsetAtOverlap()
WithMinute(Int32)
WithMonth(Int32)
WithNano(Int32)
WithSecond(Int32)
WithYear(Int32)
WithZoneSameInstant(ZoneId)
WithZoneSameLocal(ZoneId)

Explicit Interface Implementations

IChronoZonedDateTime.Plus(Int64, ITemporalUnit)
IChronoZonedDateTime.ToLocalDateTime()
IChronoZonedDateTime.With(ITemporalField, Int64)
IChronoZonedDateTime.WithEarlierOffsetAtOverlap()
IChronoZonedDateTime.WithLaterOffsetAtOverlap()
IChronoZonedDateTime.WithZoneSameInstant(ZoneId)
IChronoZonedDateTime.WithZoneSameLocal(ZoneId)
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