Freigeben über


DateIntervalInfo.SetIntervalPattern(String, CalendarField, String) Method

Definition

Provides a way for client to build interval patterns.

[Android.Runtime.Register("setIntervalPattern", "(Ljava/lang/String;ILjava/lang/String;)V", "GetSetIntervalPattern_Ljava_lang_String_ILjava_lang_String_Handler", ApiSince=24)]
public virtual void SetIntervalPattern (string? skeleton, Android.Icu.Util.CalendarField lrgDiffCalUnit, string? intervalPattern);
[<Android.Runtime.Register("setIntervalPattern", "(Ljava/lang/String;ILjava/lang/String;)V", "GetSetIntervalPattern_Ljava_lang_String_ILjava_lang_String_Handler", ApiSince=24)>]
abstract member SetIntervalPattern : string * Android.Icu.Util.CalendarField * string -> unit
override this.SetIntervalPattern : string * Android.Icu.Util.CalendarField * string -> unit

Parameters

skeleton
String

the skeleton on which interval pattern based

lrgDiffCalUnit
CalendarField

the largest different calendar unit.

intervalPattern
String

the interval pattern on the largest different calendar unit. For example, if lrgDiffCalUnit is "year", the interval pattern for en_US when year is different could be "'from' yyyy 'to' yyyy".

Attributes

Remarks

Provides a way for client to build interval patterns. User could construct DateIntervalInfo by providing a list of skeletons and their patterns.

For example:

DateIntervalInfo dIntervalInfo = new DateIntervalInfo();
            dIntervalInfo.setIntervalPattern("yMd", Calendar.YEAR, "'from' yyyy-M-d 'to' yyyy-M-d");
            dIntervalInfo.setIntervalPattern("yMMMd", Calendar.MONTH, "'from' yyyy MMM d 'to' MMM d");
            dIntervalInfo.setIntervalPattern("yMMMd", Calendar.DAY, "yyyy MMM d-d");
            dIntervalInfo.setFallbackIntervalPattern("{0} ~ {1}");

Restriction: Currently, users can only set interval patterns when the following calendar fields are different: ERA, YEAR, MONTH, DATE, DAY_OF_MONTH, DAY_OF_WEEK, AM_PM, HOUR, HOUR_OF_DAY, MINUTE, SECOND, and MILLISECOND. Interval patterns when other calendar fields are different are not supported.

Java documentation for android.icu.text.DateIntervalInfo.setIntervalPattern(java.lang.String, int, java.lang.String).

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.

Applies to