Added in API level 1

DateFormatSymbols

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

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. SimpleDateFormat uses 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, DateFormatSymbols.getInstance(aLocale)).
  

DateFormatSymbols objects are cloneable. 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

Public constructors

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

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

Public methods
open Any

Overrides Cloneable

open Boolean
equals(other: Any?)

Override equals

open Array<String!>!

Gets ampm 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!>!

Gets era strings.

static DateFormatSymbols!

Gets the DateFormatSymbols instance for the default locale.

static DateFormatSymbols!
getInstance(locale: Locale!)

Gets the DateFormatSymbols instance for the specified locale.

open String!

Gets localized date-time pattern characters.

open Array<String!>!

Gets month strings.

open Array<String!>!

Gets short month strings.

open Array<String!>!

Gets short weekday strings.

open Array<String!>!

Gets weekday strings.

open Array<Array<String!>!>!

Gets time zone strings.

open Int

Override hashCode.

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

Sets ampm strings.

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

Sets era strings.

open Unit
setLocalPatternChars(newLocalPatternChars: String!)

Sets localized date-time pattern characters.

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

Sets month strings.

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

Sets short month strings.

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

Sets short weekday strings.

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

Sets weekday strings.

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

Sets time zone strings.

Public constructors

DateFormatSymbols

Added in API level 1
DateFormatSymbols()

Construct a DateFormatSymbols object by loading format data from resources for the default FORMAT locale. It is recommended that the getInstance method is used instead.

This is equivalent to calling DateFormatSymbols(Locale.getDefault(Locale.Category.FORMAT)).

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

DateFormatSymbols

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

Construct a DateFormatSymbols object by loading format data from resources for the given locale. It is recommended that the getInstance method is used instead.

Parameters
locale Locale!: the desired locale
Exceptions
java.util.MissingResourceException if the resources for the specified locale cannot be found or cannot be loaded.

Public methods

clone

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

Overrides Cloneable

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 1
open fun equals(other: Any?): Boolean

Override 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 1
open fun getAmPmStrings(): Array<String!>!

Gets ampm strings. For example: "AM" and "PM".

Return
Array<String!>! the ampm strings.

getAvailableLocales

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

Returns an array of all locales for which the getInstance methods of this class can return localized instances. It must contain at least a Locale instance equal to Locale.US.

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

getEras

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

Gets era strings. For example: "AD" and "BC".

Return
Array<String!>! the era strings.

getInstance

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

Gets the DateFormatSymbols instance for the default locale.

This is equivalent to calling getInstance(Locale.getDefault(Locale.Category.FORMAT)).

Return
DateFormatSymbols! a DateFormatSymbols instance.

getInstance

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

Gets the DateFormatSymbols instance for the specified locale.

Parameters
locale Locale!: the given locale.
Return
DateFormatSymbols! a DateFormatSymbols instance.
Exceptions
java.lang.NullPointerException if locale is null

getLocalPatternChars

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

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

Return
String! the localized date-time pattern characters.

getMonths

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

Gets month strings. For example: "January", "February", etc. An array with either 12 or 13 elements will be returned depending on whether or not Calendar.UNDECIMBER is supported. Use Calendar.JANUARY, Calendar.FEBRUARY, etc. to index the result array.

If the language requires different forms for formatting and stand-alone usages, this method returns month names in the formatting form. For example, the preferred month name for January in the Czech language is ledna in the formatting form, while it is leden in the stand-alone form. This method returns "ledna" in this case. Refer to the Calendar Elements in the Unicode Locale Data Markup Language (LDML) specification for more details.

Return
Array<String!>! the month strings.

getShortMonths

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

Gets short month strings. For example: "Jan", "Feb", etc. An array with either 12 or 13 elements will be returned depending on whether or not Calendar.UNDECIMBER is supported. Use Calendar.JANUARY, Calendar.FEBRUARY, etc. to index the result array.

If the language requires different forms for formatting and stand-alone usages, this method returns short month names in the formatting form. For example, the preferred abbreviation for January in the Catalan language is de gen. in the formatting form, while it is gen. in the stand-alone form. This method returns "de gen." in this case. Refer to the Calendar Elements in the Unicode Locale Data Markup Language (LDML) specification for more details.

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

getShortWeekdays

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

Gets short weekday strings. For example: "Sun", "Mon", etc.

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

getWeekdays

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

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

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

getZoneStrings

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

Gets time zone strings. Use of this method is discouraged; use TimeZone.getDisplayName() instead.

The value returned is a two-dimensional array of strings of size n by m, where m is at least 5. Each of the n rows is an entry containing the localized names for a single TimeZone. Each such row contains (with i ranging from 0..n-1):

  • zoneStrings[i][0] - time zone ID
  • zoneStrings[i][1] - long name of zone in standard time
  • zoneStrings[i][2] - short name of zone in standard time
  • zoneStrings[i][3] - long name of zone in daylight saving time
  • zoneStrings[i][4] - short name of zone in daylight saving time
The zone ID is not localized; it's one of the valid IDs of the TimeZone class that are not custom IDs. All other entries are localized names. If a zone does not implement daylight saving time, the daylight saving time names should not be used.

If setZoneStrings has been called on this DateFormatSymbols instance, then the strings provided by that call are returned. Otherwise, the returned array contains names provided by the runtime.

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

hashCode

Added in API level 1
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 1
open fun setAmPmStrings(newAmpms: Array<String!>!): Unit

Sets ampm strings. For example: "AM" and "PM".

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

setEras

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

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

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

setLocalPatternChars

Added in API level 1
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 1
open fun setMonths(newMonths: Array<String!>!): Unit

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

Parameters
newMonths Array<String!>!: the new month strings. The array should be indexed by Calendar.JANUARY, Calendar.FEBRUARY, etc.

setShortMonths

Added in API level 1
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. The array should be indexed by Calendar.JANUARY, Calendar.FEBRUARY, etc.

setShortWeekdays

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

Sets short weekday strings. For example: "Sun", "Mon", etc.

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

setWeekdays

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

Sets 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.

setZoneStrings

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

Sets time zone strings. The argument must be a two-dimensional array of strings of size n by m, where m is at least 5. Each of the n rows is an entry containing the localized names for a single TimeZone. Each such row contains (with i ranging from 0..n-1):

  • zoneStrings[i][0] - time zone ID
  • zoneStrings[i][1] - long name of zone in standard time
  • zoneStrings[i][2] - short name of zone in standard time
  • zoneStrings[i][3] - long name of zone in daylight saving time
  • zoneStrings[i][4] - short name of zone in daylight saving time
The zone ID is not localized; it's one of the valid IDs of the TimeZone class that are not custom IDs. All other entries are localized names.

Parameters
newZoneStrings Array<Array<String!>!>!: the new time zone strings.
Exceptions
java.lang.IllegalArgumentException if the length of any row in newZoneStrings is less than 5
java.lang.NullPointerException if newZoneStrings is null