Share via


DateFormat.GetBestDateTimePattern(Locale, String) Method

Definition

Returns the best possible localized form of the given skeleton for the given locale.

[Android.Runtime.Register("getBestDateTimePattern", "(Ljava/util/Locale;Ljava/lang/String;)Ljava/lang/String;", "")]
public static string? GetBestDateTimePattern (Java.Util.Locale? locale, string? skeleton);
[<Android.Runtime.Register("getBestDateTimePattern", "(Ljava/util/Locale;Ljava/lang/String;)Ljava/lang/String;", "")>]
static member GetBestDateTimePattern : Java.Util.Locale * string -> string

Parameters

locale
Locale

the locale into which the skeleton should be localized

skeleton
String

a skeleton as described above

Returns

a string pattern suitable for use with java.text.SimpleDateFormat.

Attributes

Remarks

Returns the best possible localized form of the given skeleton for the given locale. A skeleton is similar to, and uses the same format characters as, a Unicode UTS #35 pattern.

One difference is that order is irrelevant. For example, "MMMMd" will return "MMMM d" in the en_US locale, but "d. MMMM" in the de_CH locale.

Note also in that second example that the necessary punctuation for German was added. For the same input in es_ES, we'd have even more extra text: "d 'de' MMMM".

This method will automatically correct for grammatical necessity. Given the same "MMMMd" input, this method will return "d LLLL" in the fa_IR locale, where stand-alone months are necessary. Lengths are preserved where meaningful, so "Md" would give a different result to "MMMd", say, except in a locale such as ja_JP where there is only one length of month.

This method will only return patterns that are in CLDR, and is useful whenever you know what elements you want in your format string but don't want to make your code specific to any one locale.

Java documentation for android.text.format.DateFormat.getBestDateTimePattern(java.util.Locale, 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