Compartilhar via


Time Class

Definition

An alternative to the java.util.Calendar and java.util.GregorianCalendar classes.

[Android.Runtime.Register("android/text/format/Time", DoNotGenerateAcw=true)]
public class Time : Java.Lang.Object
[<Android.Runtime.Register("android/text/format/Time", DoNotGenerateAcw=true)>]
type Time = class
    inherit Object
Inheritance
Time
Attributes

Remarks

An alternative to the java.util.Calendar and java.util.GregorianCalendar classes. An instance of the Time class represents a moment in time, specified with second precision. It is modelled after struct tm. This class is not thread-safe and does not consider leap seconds.

This class has a number of issues and it is recommended that java.util.GregorianCalendar is used instead.

Known issues: <ul> <li>For historical reasons when performing time calculations all arithmetic currently takes place using 32-bit integers. This limits the reliable time range representable from 1902 until 2037.See the wikipedia article on the Year 2038 problem for details. Do not rely on this behavior; it may change in the future. </li> <li>Calling #switchTimezone(String) on a date that cannot exist, such as a wall time that was skipped due to a DST transition, will result in a date in 1969 (i.e. -1, or 1 second before 1st Jan 1970 UTC).</li> <li>Much of the formatting / parsing assumes ASCII text and is therefore not suitable for use with non-ASCII scripts.</li> <li>No support for pseudo-zones like "GMT-07:00".</li> </ul>

This member is deprecated. Use java.util.GregorianCalendar instead.

Java documentation for android.text.format.Time.

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

Time()

Construct a Time object in the default timezone.

Time(IntPtr, JniHandleOwnership)

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

Time(String)

Construct a Time object in the timezone named by the string argument "timezone".

Time(Time)

A copy constructor.

Fields

EpochJulianDay

The Julian day of the epoch, that is, January 1, 1970 on the Gregorian calendar.

TimezoneUtc

Properties

AllDay

True if this is an allDay event.

Class

Returns the runtime class of this Object.

(Inherited from Object)
CurrentTimezone

Returns the timezone string that is currently set for the device.

Gmtoff

Offset in seconds from UTC including any DST offset.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
Hour

Hour of day [0-23]

IsDst

This time is in daylight savings time.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Minute

Minute [0-59]

Month

Month [0-11]

MonthDay

Day of month [1-31]

PeerReference (Inherited from Object)
Second

Seconds [0-61] (2 leap seconds allowed)

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.

Timezone

The timezone for this Time.

WeekDay

Day of week [0-6]

WeekNumber

Computes the week number according to ISO 8601.

Year

Year.

YearDay

Day of year [0-365]

Methods

After(Time)

Returns true if the time represented by this Time object occurs after the given time.

Before(Time)

Returns true if the time represented by this Time object occurs before the given time.

Clear(String)

Clears all values, setting the timezone to the given timezone.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Compare(Time, Time)

Compare two Time objects and return a negative number if a is less than b, a positive number if a is greater than b, or 0 if they are equal.

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(String)

Print the current value given the format string provided.

Format2445()

Format according to RFC 2445 DATE-TIME type.

Format3339(Boolean)

Return a string in the RFC 3339 format.

GetActualMaximum(TimeFormatValues)

Return the maximum possible value for the given field given the value of the other fields.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetJulianDay(Int64, Int64)

Computes the Julian day number for a point in time in a particular timezone.

GetJulianMondayFromWeeksSinceEpoch(Int32)

Takes a number of weeks since the epoch and calculates the Julian day of the Monday for that week.

GetWeeksSinceEpochFromJulianDay(Int32, Int32)

Returns the week since #EPOCH_JULIAN_DAY (Jan 1, 1970) adjusted for first day of week.

IsEpoch(Time)

Returns true if the instant of the supplied time would be for the Gregorian calendar date January 1, 1970 <em>for a user observing UTC </em>, i.

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)
Normalize(Boolean)

Ensures the values in each field are in range.

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)
Parse(String)

Parses a date-time string in either the RFC 2445 format or an abbreviated format that does not include the "time" field.

Parse3339(String)

Parse a time in RFC 3339 format.

Set(Int32, Int32, Int32, Int32, Int32, Int32)

Sets the fields.

Set(Int32, Int32, Int32)

Sets the date from the given fields.

Set(Int64)

Sets the fields in this Time object given the UTC milliseconds.

Set(Time)

Copy the value of that to this Time object.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetJulianDay(Int32)

Sets the time from the given Julian day number, which must be based on the same timezone that is set in this Time object.

SetToNow()

Sets the time of the given Time object to the current time.

SwitchTimezone(String)

Convert this time object so the time represented remains the same, but is instead located in a different timezone.

ToArray<T>() (Inherited from Object)
ToMillis(Boolean)

Converts this time to milliseconds.

ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
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