DateFormatSymbols
open class DateFormatSymbols : Cloneable, Serializable
[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 |
|
DateFormatSymbols(cal: Calendar!, locale: ULocale!) Returns the |
|
DateFormatSymbols(cal: Calendar!, locale: Locale!) Returns the |
|
DateFormatSymbols(locale: ULocale!) [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. |
|
DateFormatSymbols(locale: Locale!) Constructs a DateFormatSymbols object by loading format data from resources for the given locale. |
|
DateFormatSymbols(bundle: ResourceBundle!, locale: ULocale!) Fetches a custom calendar's DateFormatSymbols out of the given resource bundle. |
|
DateFormatSymbols(bundle: ResourceBundle!, locale: Locale!) Fetches a custom calendar's DateFormatSymbols out of the given resource bundle. |
Public methods | |
---|---|
open Any |
clone() Overrides clone. |
open Boolean |
Overrides equals. |
open Array<String!>! |
Returns am/pm strings. |
open static Array<Locale!>! |
Returns an array of all locales for which the |
open Array<String!>! |
[icu] Returns full era name strings. |
open Array<String!>! |
getEras() 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!>! |
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 |
hashCode() 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 |
Sets abbreviated era strings. |
open Unit |
setLocalPatternChars(newLocalPatternChars: String!) Sets localized date-time pattern characters. |
open Unit |
Sets month strings. |
open Unit |
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
SHORT
static val SHORT: Int
[icu] Constant for width; only supported for weekdays.
Value: 3
Public constructors
DateFormatSymbols
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
DateFormatSymbols(
cal: Calendar!,
locale: ULocale!)
Returns the DateFormatSymbols
object that should be used to format a calendar system's dates in the given locale.
DateFormatSymbols
DateFormatSymbols(
cal: Calendar!,
locale: Locale!)
Returns the DateFormatSymbols
object that should be used to format a calendar system's dates in the given locale.
DateFormatSymbols
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
DateFormatSymbols(
calendarClass: Class<out Calendar!>!,
locale: ULocale!)
Variant of DateFormatSymbols(Calendar, ULocale) that takes the Calendar class instead of a Calendar instance.
See Also
DateFormatSymbols
DateFormatSymbols(
calendarClass: Class<out Calendar!>!,
locale: Locale!)
Variant of DateFormatSymbols(Calendar, Locale) that takes the Calendar class instead of a Calendar instance.
See Also
DateFormatSymbols
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
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
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
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
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
open fun getAmPmStrings(): Array<String!>!
Returns am/pm strings. For example: "AM" and "PM".
getAvailableLocales
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 Locale
s available in this class. ICU does not support DateFormatSymbolsProvider
introduced in Java 6 or its equivalent implementation for now.
getEraNames
open fun getEraNames(): Array<String!>!
[icu] Returns full era name strings. For example: "Anno Domini" and "Before Christ".
getEras
open fun getEras(): Array<String!>!
Returns abbreviated era strings. For example: "AD" and "BC".
getInstance
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
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
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
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
open fun getMonths(): Array<String!>!
Returns month strings. For example: "January", "February", etc.
getMonths
open fun getMonths(
context: Int,
width: Int
): Array<String!>!
Returns month strings. For example: "January", "February", etc.
getNarrowEras
open fun getNarrowEras(): Array<String!>!
[icu] Returns narrow era name strings. For example: "A" and "B".
getQuarters
open fun getQuarters(
context: Int,
width: Int
): Array<String!>!
[icu] Returns quarter strings. For example: "1st Quarter", "2nd Quarter", etc.
getShortMonths
open fun getShortMonths(): Array<String!>!
Returns short month strings. For example: "Jan", "Feb", etc.
getShortWeekdays
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.)
getWeekdays
open fun getWeekdays(): Array<String!>!
Returns wide weekday strings. For example: "Sunday", "Monday", etc.
getWeekdays
open fun getWeekdays(
context: Int,
width: Int
): Array<String!>!
Returns weekday strings. For example: "Sunday", "Monday", etc.
getYearNames
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.
getZodiacNames
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.
getZoneStrings
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
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.
hashCode
open fun hashCode(): Int
Override hashCode. Generates a hash code for the DateFormatSymbols object.
Return | |
---|---|
Int |
a hash code value for this object. |
setAmPmStrings
open fun setAmPmStrings(newAmpms: Array<String!>!): Unit
Sets am/pm strings. For example: "AM" and "PM".
setEraNames
open fun setEraNames(newEraNames: Array<String!>!): Unit
[icu] Sets full era name strings. For example: "Anno Domini" and "Before Christ".
setEras
open fun setEras(newEras: Array<String!>!): Unit
Sets abbreviated era strings. For example: "AD" and "BC".
setLocalPatternChars
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
open fun setMonths(newMonths: Array<String!>!): Unit
Sets month strings. For example: "January", "February", etc.
setMonths
open fun setMonths(
newMonths: Array<String!>!,
context: Int,
width: Int
): Unit
Sets month strings. For example: "January", "February", etc.
setNarrowEras
open fun setNarrowEras(newNarrowEras: Array<String!>!): Unit
[icu] Sets narrow era name strings. For example: "A" and "B".
setQuarters
open fun setQuarters(
newQuarters: Array<String!>!,
context: Int,
width: Int
): Unit
[icu] Sets quarter strings. For example: "1st Quarter", "2nd Quarter", etc.
setShortMonths
open fun setShortMonths(newShortMonths: Array<String!>!): Unit
Sets short month strings. For example: "Jan", "Feb", etc.
setShortWeekdays
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.)
setWeekdays
open fun setWeekdays(newWeekdays: Array<String!>!): Unit
Sets wide weekday strings. For example: "Sunday", "Monday", etc.
setWeekdays
open fun setWeekdays(
newWeekdays: Array<String!>!,
context: Int,
width: Int
): Unit
Sets weekday strings. For example: "Sunday", "Monday", etc.
setYearNames
open fun setYearNames(
yearNames: Array<String!>!,
context: Int,
width: Int
): Unit
Sets cyclic year name strings, for example: "jia-zi", "yi-chou", etc.
setZodiacNames
open fun setZodiacNames(
zodiacNames: Array<String!>!,
context: Int,
width: Int
): Unit
Sets calendar zodiac name strings, for example: "Rat", "Ox", "Tiger", etc.
setZoneStrings
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.
Protected methods
initializeData
protected open fun initializeData(
desiredLocale: ULocale!,
type: String!
): Unit
Initializes format symbols for the locale and calendar type