Added in API level 24

DateFormatSymbols


open class DateFormatSymbols : Cloneable, Serializable
kotlin.Any
   ↳ android.icu.text.DateFormatSymbols

[icu enhancement] ICU's replacement for java.text.DateFormatSymbols. Methods, fields, and other functionality specific to ICU are labeled '[icu]'.

DateFormatSymbols is a public class for encapsulating localizable date-time formatting data, such as the names of the months, the names of the days of the week, and the time zone data. DateFormat and SimpleDateFormat both use DateFormatSymbols to encapsulate this information.

Typically you shouldn't use DateFormatSymbols directly. Rather, you are encouraged to create a date-time formatter with the DateFormat class's factory methods: getTimeInstance, getDateInstance, or getDateTimeInstance. These methods automatically create a DateFormatSymbols for the formatter so that you don't have to. After the formatter is created, you may modify its format pattern using the setPattern method. For more information about creating formatters using DateFormat's factory methods, see DateFormat.

If you decide to create a date-time formatter with a specific format pattern for a specific locale, you can do so with:

new SimpleDateFormat(aPattern, new DateFormatSymbols(aLocale)).
  

DateFormatSymbols objects are clonable. When you obtain a DateFormatSymbols object, feel free to modify the date-time formatting data. For instance, you can replace the localized date-time format pattern characters with the ones that you feel easy to remember. Or you can change the representative cities to your favorite ones.

New DateFormatSymbols subclasses may be added to support SimpleDateFormat for date-time formatting for additional locales.

Summary

Constants
static Int

[icu] Constant for width.

static Int

[icu] Constant for context.

static Int

[icu] Constant for width.

static Int

[icu] Constant for width; only supported for weekdays.

static Int

[icu] Constant for context.

static Int

[icu] Constant for width.

Public constructors

Constructs a DateFormatSymbols object by loading format data from resources for the default FORMAT locale.

Returns the DateFormatSymbols object that should be used to format a calendar system's dates in the given locale.

DateFormatSymbols(cal: Calendar!, locale: Locale!)

Returns the DateFormatSymbols object that should be used to format a calendar system's dates in the given locale.

[icu] Constructs a DateFormatSymbols object by loading format data from resources for the given ulocale.

DateFormatSymbols(calendarClass: Class<out Calendar!>!, locale: ULocale!)

Variant of DateFormatSymbols(Calendar, ULocale) that takes the Calendar class instead of a Calendar instance.

DateFormatSymbols(calendarClass: Class<out Calendar!>!, locale: Locale!)

Variant of DateFormatSymbols(Calendar, Locale) that takes the Calendar class instead of a Calendar instance.

Constructs a DateFormatSymbols object by loading format data from resources for the given locale.

Fetches a custom calendar's DateFormatSymbols out of the given resource bundle.

Fetches a custom calendar's DateFormatSymbols out of the given resource bundle.

Public methods
open Any

Overrides clone.

open Boolean
equals(other: Any?)

Overrides equals.

open Array<String!>!

Returns am/pm strings.

open static Array<Locale!>!

Returns an array of all locales for which the getInstance methods of this class can return localized instances.

open Array<String!>!

[icu] Returns full era name strings.

open Array<String!>!

Returns abbreviated era strings.

open static DateFormatSymbols!

Returns a DateFormatSymbols instance for the default locale.

open static DateFormatSymbols!
getInstance(locale: ULocale!)

[icu] Returns a DateFormatSymbols instance for the given locale.

open static DateFormatSymbols!
getInstance(locale: Locale!)

Returns a DateFormatSymbols instance for the given locale.

open String!

Returns localized date-time pattern characters.

open Array<String!>!

Returns month strings.

open Array<String!>!
getMonths(context: Int, width: Int)

Returns month strings.

open Array<String!>!

[icu] Returns narrow era name strings.

open Array<String!>!
getQuarters(context: Int, width: Int)

[icu] Returns quarter strings.

open Array<String!>!

Returns short month strings.

open Array<String!>!

Returns abbreviated weekday strings; for example: "Sun", "Mon", etc.

open Array<String!>!

Returns wide weekday strings.

open Array<String!>!
getWeekdays(context: Int, width: Int)

Returns weekday strings.

open Array<String!>!
getYearNames(context: Int, width: Int)

Returns cyclic year name strings if the calendar has them, for example: "jia-zi", "yi-chou", etc.

open Array<String!>!
getZodiacNames(context: Int, width: Int)

Returns calendar zodiac name strings if the calendar has them, for example: "Rat", "Ox", "Tiger", etc.

open Array<Array<String!>!>!

Returns time zone strings.

open Int

Override hashCode.

open Unit
setAmPmStrings(newAmpms: Array<String!>!)

Sets am/pm strings.

open Unit
setEraNames(newEraNames: Array<String!>!)

[icu] Sets full era name strings.

open Unit
setEras(newEras: Array<String!>!)

Sets abbreviated era strings.

open Unit
setLocalPatternChars(newLocalPatternChars: String!)

Sets localized date-time pattern characters.

open Unit
setMonths(newMonths: Array<String!>!)

Sets month strings.

open Unit
setMonths(newMonths: Array<String!>!, context: Int, width: Int)

Sets month strings.

open Unit
setNarrowEras(newNarrowEras: Array<String!>!)

[icu] Sets narrow era name strings.

open Unit
setQuarters(newQuarters: Array<String!>!, context: Int, width: Int)

[icu] Sets quarter strings.

open Unit
setShortMonths(newShortMonths: Array<String!>!)

Sets short month strings.

open Unit
setShortWeekdays(newAbbrevWeekdays: Array<String!>!)

Sets abbreviated weekday strings; for example: "Sun", "Mon", etc.

open Unit
setWeekdays(newWeekdays: Array<String!>!)

Sets wide weekday strings.

open Unit
setWeekdays(newWeekdays: Array<String!>!, context: Int, width: Int)

Sets weekday strings.

open Unit
setYearNames(yearNames: Array<String!>!, context: Int, width: Int)

Sets cyclic year name strings, for example: "jia-zi", "yi-chou", etc.

open Unit
setZodiacNames(zodiacNames: Array<String!>!, context: Int, width: Int)

Sets calendar zodiac name strings, for example: "Rat", "Ox", "Tiger", etc.

open Unit
setZoneStrings(newZoneStrings: Array<Array<String!>!>!)

Sets time zone strings.

Protected methods
open Unit
initializeData(desiredLocale: ULocale!, type: String!)

Initializes format symbols for the locale and calendar type

Constants

ABBREVIATED

Added in API level 24
static val ABBREVIATED: Int

[icu] Constant for width.

Value: 0

FORMAT

Added in API level 24
static val FORMAT: Int

[icu] Constant for context.

Value: 0

NARROW

Added in API level 24
static val NARROW: Int

[icu] Constant for width.

Value: 2

SHORT

Added in API level 24
static val SHORT: Int

[icu] Constant for width; only supported for weekdays.

Value: 3

STANDALONE

Added in API level 24
static val STANDALONE: Int

[icu] Constant for context.

Value: 1

WIDE

Added in API level 24
static val WIDE: Int

[icu] Constant for width.

Value: 1

Public constructors

DateFormatSymbols

Added in API level 24
DateFormatSymbols()

Constructs a DateFormatSymbols object by loading format data from resources for the default FORMAT locale.

Exceptions
java.util.MissingResourceException if the resources for the default locale cannot be found or cannot be loaded.

DateFormatSymbols

Added in API level 24
DateFormatSymbols(
    cal: Calendar!,
    locale: ULocale!)

Returns the DateFormatSymbols object that should be used to format a calendar system's dates in the given locale.

Parameters
cal Calendar!: The calendar system whose date format symbols are desired.
locale ULocale!: The ulocale whose symbols are desired.

DateFormatSymbols

Added in API level 24
DateFormatSymbols(
    cal: Calendar!,
    locale: Locale!)

Returns the DateFormatSymbols object that should be used to format a calendar system's dates in the given locale.

Parameters
cal Calendar!: The calendar system whose date format symbols are desired.
locale Locale!: The locale whose symbols are desired.

DateFormatSymbols

Added in API level 24
DateFormatSymbols(locale: ULocale!)

[icu] Constructs a DateFormatSymbols object by loading format data from resources for the given ulocale.

Exceptions
java.util.MissingResourceException if the resources for the specified locale cannot be found or cannot be loaded.

DateFormatSymbols

Added in API level 24
DateFormatSymbols(
    calendarClass: Class<out Calendar!>!,
    locale: ULocale!)

Variant of DateFormatSymbols(Calendar, ULocale) that takes the Calendar class instead of a Calendar instance.

DateFormatSymbols

Added in API level 24
DateFormatSymbols(
    calendarClass: Class<out Calendar!>!,
    locale: Locale!)

Variant of DateFormatSymbols(Calendar, Locale) that takes the Calendar class instead of a Calendar instance.

DateFormatSymbols

Added in API level 24
DateFormatSymbols(locale: Locale!)

Constructs a DateFormatSymbols object by loading format data from resources for the given locale.

Exceptions
java.util.MissingResourceException if the resources for the specified locale cannot be found or cannot be loaded.

DateFormatSymbols

Added in API level 24
DateFormatSymbols(
    bundle: ResourceBundle!,
    locale: ULocale!)

Fetches a custom calendar's DateFormatSymbols out of the given resource bundle. Symbols that are not overridden are inherited from the default DateFormatSymbols for the locale.

DateFormatSymbols

Added in API level 24
DateFormatSymbols(
    bundle: ResourceBundle!,
    locale: Locale!)

Fetches a custom calendar's DateFormatSymbols out of the given resource bundle. Symbols that are not overridden are inherited from the default DateFormatSymbols for the locale.

Public methods

clone

Added in API level 24
open fun clone(): Any

Overrides clone.

Return
Any a clone of this instance.
Exceptions
java.lang.CloneNotSupportedException if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

equals

Added in API level 24
open fun equals(other: Any?): Boolean

Overrides equals.

Parameters
obj the reference object with which to compare.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getAmPmStrings

Added in API level 24
open fun getAmPmStrings(): Array<String!>!

Returns am/pm strings. For example: "AM" and "PM".

Return
Array<String!>! the weekday strings.

getAvailableLocales

Added in API level 24
open static fun getAvailableLocales(): Array<Locale!>!

Returns an array of all locales for which the getInstance methods of this class can return localized instances. [icu] Note: Unlike java.text.DateFormatSymbols#getAvailableLocales, this method simply returns the array of Locales available in this class. ICU does not support DateFormatSymbolsProvider introduced in Java 6 or its equivalent implementation for now.

Return
Array<Locale!>! An array of Locales for which localized DateFormatSymbols instances are available.

getEraNames

Added in API level 24
open fun getEraNames(): Array<String!>!

[icu] Returns full era name strings. For example: "Anno Domini" and "Before Christ".

Return
Array<String!>! the era strings.

getEras

Added in API level 24
open fun getEras(): Array<String!>!

Returns abbreviated era strings. For example: "AD" and "BC".

Return
Array<String!>! the era strings.

getInstance

Added in API level 24
open static fun getInstance(): DateFormatSymbols!

Returns a DateFormatSymbols instance for the default locale. [icu] Note: Unlike java.text.DateFormatSymbols#getInstance, this method simply returns new android.icu.text.DateFormatSymbols(). ICU does not support DateFormatSymbolsProvider introduced in Java 6 or its equivalent implementation for now.

Return
DateFormatSymbols! A DateFormatSymbols instance.

getInstance

Added in API level 24
open static fun getInstance(locale: ULocale!): DateFormatSymbols!

[icu] Returns a DateFormatSymbols instance for the given locale. [icu] Note: Unlike java.text.DateFormatSymbols#getInstance, this method simply returns new android.icu.text.DateFormatSymbols(locale). ICU does not support DateFormatSymbolsProvider introduced in Java 6 or its equivalent implementation for now.

Parameters
locale ULocale!: the locale.
Return
DateFormatSymbols! A DateFormatSymbols instance.

getInstance

Added in API level 24
open static fun getInstance(locale: Locale!): DateFormatSymbols!

Returns a DateFormatSymbols instance for the given locale. [icu] Note: Unlike java.text.DateFormatSymbols#getInstance, this method simply returns new android.icu.text.DateFormatSymbols(locale). ICU does not support DateFormatSymbolsProvider introduced in Java 6 or its equivalent implementation for now.

Parameters
locale Locale!: the locale.
Return
DateFormatSymbols! A DateFormatSymbols instance.

getLocalPatternChars

Added in API level 24
open fun getLocalPatternChars(): String!

Returns localized date-time pattern characters. For example: 'u', 't', etc.

Note: ICU no longer provides localized date-time pattern characters for a locale starting ICU 3.8. This method returns the non-localized date-time pattern characters unless user defined localized data is set by setLocalPatternChars.

Return
String! the localized date-time pattern characters.

getMonths

Added in API level 24
open fun getMonths(): Array<String!>!

Returns month strings. For example: "January", "February", etc.

Return
Array<String!>! the month strings.

getMonths

Added in API level 24
open fun getMonths(
    context: Int,
    width: Int
): Array<String!>!

Returns month strings. For example: "January", "February", etc.

Parameters
context Int: The month context, FORMAT or STANDALONE.
width Int: The width or the returned month string, either WIDE, ABBREVIATED, or NARROW.
Return
Array<String!>! the month strings.

getNarrowEras

Added in API level 31
open fun getNarrowEras(): Array<String!>!

[icu] Returns narrow era name strings. For example: "A" and "B".

Return
Array<String!>! the narrow era strings.

getQuarters

Added in API level 24
open fun getQuarters(
    context: Int,
    width: Int
): Array<String!>!

[icu] Returns quarter strings. For example: "1st Quarter", "2nd Quarter", etc.

Parameters
context Int: The quarter context, FORMAT or STANDALONE.
width Int: The width or the returned quarter string, WIDE, NARROW, or ABBREVIATED.
Return
Array<String!>! the quarter strings.

getShortMonths

Added in API level 24
open fun getShortMonths(): Array<String!>!

Returns short month strings. For example: "Jan", "Feb", etc.

Return
Array<String!>! the short month strings.

getShortWeekdays

Added in API level 24
open fun getShortWeekdays(): Array<String!>!

Returns abbreviated weekday strings; for example: "Sun", "Mon", etc. (Note: the method name is misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)

Return
Array<String!>! the abbreviated weekday strings. Use Calendar.SUNDAY, Calendar.MONDAY, etc. to index the result array.

getWeekdays

Added in API level 24
open fun getWeekdays(): Array<String!>!

Returns wide weekday strings. For example: "Sunday", "Monday", etc.

Return
Array<String!>! the weekday strings. Use Calendar.SUNDAY, Calendar.MONDAY, etc. to index the result array.

getWeekdays

Added in API level 24
open fun getWeekdays(
    context: Int,
    width: Int
): Array<String!>!

Returns weekday strings. For example: "Sunday", "Monday", etc.

Parameters
context Int: Formatting context, either FORMAT or STANDALONE.
width Int: Width of strings to be returned, either WIDE, ABBREVIATED, SHORT, or NARROW
Return
Array<String!>! the weekday strings. Use Calendar.SUNDAY, Calendar.MONDAY, etc. to index the result array.

getYearNames

Added in API level 24
open fun getYearNames(
    context: Int,
    width: Int
): Array<String!>!

Returns cyclic year name strings if the calendar has them, for example: "jia-zi", "yi-chou", etc.

Parameters
context Int: The usage context: FORMAT, STANDALONE.
width Int: The requested name width: WIDE, ABBREVIATED, SHORT, NARROW.
Return
Array<String!>! The year name strings, or null if they are not available for this calendar.

getZodiacNames

Added in API level 24
open fun getZodiacNames(
    context: Int,
    width: Int
): Array<String!>!

Returns calendar zodiac name strings if the calendar has them, for example: "Rat", "Ox", "Tiger", etc.

Parameters
context Int: The usage context: FORMAT, STANDALONE.
width Int: The requested name width: WIDE, ABBREVIATED, SHORT, NARROW.
Return
Array<String!>! The zodiac name strings, or null if they are not available for this calendar.

getZoneStrings

Added in API level 24
open fun getZoneStrings(): Array<Array<String!>!>!

Returns time zone strings.

The array returned by this API is a two dimensional String array and each row contains at least following strings:

  • ZoneStrings[n][0] - System time zone ID
  • ZoneStrings[n][1] - Long standard time display name
  • ZoneStrings[n][2] - Short standard time display name
  • ZoneStrings[n][3] - Long daylight saving time display name
  • ZoneStrings[n][4] - Short daylight saving time display name
When a localized display name is not available, the corresponding array element will be null.

Note: ICU implements the time zone display name formatting algorithm specified by UTS#35 Unicode Locale Data Markup Language(LDML). The algorithm supports historic display name changes and various different types of names not available in java.text.DateFormatSymbols#getZoneStrings(). For accessing the full set of time zone string data used by ICU implementation, you should use TimeZoneNames APIs instead.

Return
Array<Array<String!>!>! the time zone strings.

hashCode

Added in API level 24
open fun hashCode(): Int

Override hashCode. Generates a hash code for the DateFormatSymbols object.

Return
Int a hash code value for this object.

setAmPmStrings

Added in API level 24
open fun setAmPmStrings(newAmpms: Array<String!>!): Unit

Sets am/pm strings. For example: "AM" and "PM".

Parameters
newAmpms Array<String!>!: the new ampm strings.

setEraNames

Added in API level 24
open fun setEraNames(newEraNames: Array<String!>!): Unit

[icu] Sets full era name strings. For example: "Anno Domini" and "Before Christ".

Parameters
newEraNames Array<String!>!: the new era strings.

setEras

Added in API level 24
open fun setEras(newEras: Array<String!>!): Unit

Sets abbreviated era strings. For example: "AD" and "BC".

Parameters
newEras Array<String!>!: the new era strings.

setLocalPatternChars

Added in API level 24
open fun setLocalPatternChars(newLocalPatternChars: String!): Unit

Sets localized date-time pattern characters. For example: 'u', 't', etc.

Parameters
newLocalPatternChars String!: the new localized date-time pattern characters.

setMonths

Added in API level 24
open fun setMonths(newMonths: Array<String!>!): Unit

Sets month strings. For example: "January", "February", etc.

Parameters
newMonths Array<String!>!: the new month strings.

setMonths

Added in API level 24
open fun setMonths(
    newMonths: Array<String!>!,
    context: Int,
    width: Int
): Unit

Sets month strings. For example: "January", "February", etc.

Parameters
newMonths Array<String!>!: the new month strings.
context Int: The formatting context, FORMAT or STANDALONE.
width Int: The width of the month string, either WIDE, ABBREVIATED, or NARROW.

setNarrowEras

Added in API level 31
open fun setNarrowEras(newNarrowEras: Array<String!>!): Unit

[icu] Sets narrow era name strings. For example: "A" and "B".

Parameters
newNarrowEras Array<String!>!: the new narrow era strings.

setQuarters

Added in API level 24
open fun setQuarters(
    newQuarters: Array<String!>!,
    context: Int,
    width: Int
): Unit

[icu] Sets quarter strings. For example: "1st Quarter", "2nd Quarter", etc.

Parameters
newQuarters Array<String!>!: the new quarter strings.
context Int: The formatting context, FORMAT or STANDALONE.
width Int: The width of the quarter string, WIDE, NARROW, or ABBREVIATED.

setShortMonths

Added in API level 24
open fun setShortMonths(newShortMonths: Array<String!>!): Unit

Sets short month strings. For example: "Jan", "Feb", etc.

Parameters
newShortMonths Array<String!>!: the new short month strings.

setShortWeekdays

Added in API level 24
open fun setShortWeekdays(newAbbrevWeekdays: Array<String!>!): Unit

Sets abbreviated weekday strings; for example: "Sun", "Mon", etc. (Note: the method name is misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)

Parameters
newAbbrevWeekdays Array<String!>!: the new abbreviated weekday strings. The array should be indexed by Calendar.SUNDAY, Calendar.MONDAY, etc.

setWeekdays

Added in API level 24
open fun setWeekdays(newWeekdays: Array<String!>!): Unit

Sets wide weekday strings. For example: "Sunday", "Monday", etc.

Parameters
newWeekdays Array<String!>!: the new weekday strings. The array should be indexed by Calendar.SUNDAY, Calendar.MONDAY, etc.

setWeekdays

Added in API level 24
open fun setWeekdays(
    newWeekdays: Array<String!>!,
    context: Int,
    width: Int
): Unit

Sets weekday strings. For example: "Sunday", "Monday", etc.

Parameters
newWeekdays Array<String!>!: The new weekday strings.
context Int: The formatting context, FORMAT or STANDALONE.
width Int: The width of the strings, either WIDE, ABBREVIATED, SHORT, or NARROW.

setYearNames

Added in API level 24
open fun setYearNames(
    yearNames: Array<String!>!,
    context: Int,
    width: Int
): Unit

Sets cyclic year name strings, for example: "jia-zi", "yi-chou", etc.

Parameters
yearNames Array<String!>!: The new cyclic year name strings.
context Int: The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
width Int: The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).

setZodiacNames

Added in API level 24
open fun setZodiacNames(
    zodiacNames: Array<String!>!,
    context: Int,
    width: Int
): Unit

Sets calendar zodiac name strings, for example: "Rat", "Ox", "Tiger", etc.

Parameters
zodiacNames Array<String!>!: The new zodiac name strings.
context Int: The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
width Int: The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).

setZoneStrings

Added in API level 24
open fun setZoneStrings(newZoneStrings: Array<Array<String!>!>!): Unit

Sets time zone strings.

Note: SimpleDateFormat no longer uses the zone strings stored in a DateFormatSymbols. Therefore, the time zone strings set by this method have no effects in an instance of SimpleDateFormat for formatting time zones. If you want to customize time zone display names formatted by SimpleDateFormat, you should customize TimeZoneFormat and set the instance by SimpleDateFormat.setTimeZoneFormat(TimeZoneFormat) instead.

Parameters
newZoneStrings Array<Array<String!>!>!: the new time zone strings.

Protected methods

initializeData

Added in API level 24
protected open fun initializeData(
    desiredLocale: ULocale!,
    type: String!
): Unit

Initializes format symbols for the locale and calendar type

Parameters
desiredLocale ULocale!: The locale whose symbols are desired.
type String!: The calendar type whose date format symbols are desired.