Calendar.Builder Class

Definition

Calendar.Builder is used for creating a Calendar from various date-time parameters.

[Android.Runtime.Register("java/util/Calendar$Builder", ApiSince=26, DoNotGenerateAcw=true)]
public class Calendar.Builder : Java.Lang.Object
[<Android.Runtime.Register("java/util/Calendar$Builder", ApiSince=26, DoNotGenerateAcw=true)>]
type Calendar.Builder = class
    inherit Object
Inheritance
Calendar.Builder
Attributes

Remarks

Calendar.Builder is used for creating a Calendar from various date-time parameters.

There are two ways to set a Calendar to a date-time value. One is to set the instant parameter to a millisecond offset from the Epoch. The other is to set individual field parameters, such as Calendar#YEAR YEAR, to their desired values. These two ways can't be mixed. Trying to set both the instant and individual fields will cause an IllegalStateException to be thrown. However, it is permitted to override previous values of the instant or field parameters.

If no enough field parameters are given for determining date and/or time, calendar specific default values are used when building a Calendar. For example, if the Calendar#YEAR YEAR value isn't given for the Gregorian calendar, 1970 will be used. If there are any conflicts among field parameters, the resolution rules are applied. Therefore, the order of field setting matters.

In addition to the date-time parameters, the #setLocale(Locale) locale, #setTimeZone(TimeZone) time zone, #setWeekDefinition(int, int) week definition, and #setLenient(boolean) leniency mode parameters can be set.

<b>Examples</b>

The following are sample usages. Sample code assumes that the Calendar constants are statically imported.

The following code produces a Calendar with date 2012-12-31 (Gregorian) because Monday is the first day of a week with the ISO 8601 compatible week parameters.

Calendar cal = new Calendar.Builder().setCalendarType("iso8601")
                                   .setWeekDate(2013, 1, MONDAY).build();

The following code produces a Japanese Calendar with date 1989-01-08 (Gregorian), assuming that the default Calendar#ERA ERA is <em>Heisei</em> that started on that day.

Calendar cal = new Calendar.Builder().setCalendarType("japanese")
                                   .setFields(YEAR, 1, DAY_OF_YEAR, 1).build();

Added in 1.8.

Java documentation for java.util.Calendar.Builder.

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

Calendar.Builder()

Constructs a Calendar.Builder.

Calendar.Builder(IntPtr, JniHandleOwnership)

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass
ThresholdType

Methods

Build()

Returns a Calendar built from the parameters set by the setter methods.

Clone()

Creates and returns a copy of this object.

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

Returns a hash code value for the object.

(Inherited from Object)
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)
Set(CalendarField, Int32)
SetCalendarType(String)
SetDate(Int32, Int32, Int32)
SetFields(Int32[])
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetInstant(Date)
SetInstant(Int64)
SetLenient(Boolean)
SetLocale(Locale)
SetTimeOfDay(Int32, Int32, Int32)
SetTimeOfDay(Int32, Int32, Int32, Int32)
SetTimeZone(TimeZone)
SetWeekDate(Int32, Int32, Int32)
SetWeekDefinition(Int32, Int32)
ToArray<T>() (Inherited from Object)
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)

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, 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)

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