Class DateFormatSymbols
- All Implemented Interfaces:
Serializable,Cloneable
public class DateFormatSymbols extends Object implements Serializable, Cloneable
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.
Direct use of DateFormatSymbols is likely to be less efficient
because the implementation cannot make assumptions about user-supplied/user-modifiable data
to the same extent that it can with its own built-in data.
- See Also:
DateFormat,SimpleDateFormat, Serialized Form
-
Constructor Summary
Constructors Constructor Description DateFormatSymbols()Constructs a newDateFormatSymbolsinstance containing the symbols for the user's default locale.DateFormatSymbols(Locale locale)Constructs a newDateFormatSymbolsinstance containing the symbols for the specified locale. -
Method Summary
Modifier and Type Method Description Objectclone()Creates and returns a copy of thisObject.booleanequals(Object object)Compares this object with the specified object and indicates if they are equal.String[]getAmPmStrings()Returns the array of strings which represent AM and PM.static Locale[]getAvailableLocales()Returns an array of locales for which customDateFormatSymbolsinstances are available.String[]getEras()Returns the array of strings which represent BC and AD.static DateFormatSymbolsgetInstance()Returns a newDateFormatSymbolsinstance for the user's default locale.static DateFormatSymbolsgetInstance(Locale locale)Returns a newDateFormatSymbolsfor the given locale.StringgetLocalPatternChars()Returns the pattern characters used bySimpleDateFormatto specify date and time fields.String[]getMonths()Returns the array of strings containing the full names of the months.String[]getShortMonths()Returns the array of strings containing the abbreviated names of the months.String[]getShortWeekdays()Returns the array of strings containing the abbreviated names of the days of the week.String[]getWeekdays()Returns the array of strings containing the full names of the days of the week.String[][]getZoneStrings()Returns the two-dimensional array of strings containing localized names for time zones.inthashCode()Returns an integer hash code for this object.voidsetAmPmStrings(String[] data)Sets the array of strings which represent AM and PM.voidsetEras(String[] data)Sets the array of Strings which represent BC and AD.voidsetLocalPatternChars(String data)Sets the pattern characters used bySimpleDateFormatto specify date and time fields.voidsetMonths(String[] data)Sets the array of strings containing the full names of the months.voidsetShortMonths(String[] data)Sets the array of strings containing the abbreviated names of the months.voidsetShortWeekdays(String[] data)Sets the array of strings containing the abbreviated names of the days of the week.voidsetWeekdays(String[] data)Sets the array of strings containing the full names of the days of the week.voidsetZoneStrings(String[][] zoneStrings)Sets the two-dimensional array of strings containing localized names for time zones.StringtoString()Returns a string containing a concise, human-readable description of this object.
-
Constructor Details
-
DateFormatSymbols
public DateFormatSymbols()Constructs a newDateFormatSymbolsinstance containing the symbols for the user's default locale. See "Be wary of the default locale". -
DateFormatSymbols
Constructs a newDateFormatSymbolsinstance containing the symbols for the specified locale.- Parameters:
locale- the locale.
-
-
Method Details
-
getInstance
Returns a newDateFormatSymbolsinstance for the user's default locale. See "Be wary of the default locale".- Returns:
- an instance of
DateFormatSymbols - Since:
- 1.6
-
getInstance
Returns a newDateFormatSymbolsfor the given locale.- Parameters:
locale- the locale- Returns:
- an instance of
DateFormatSymbols - Throws:
NullPointerException- iflocale == null- Since:
- 1.6
-
getAvailableLocales
Returns an array of locales for which customDateFormatSymbolsinstances are available.Note that Android does not support user-supplied locale service providers.
- Since:
- 1.6
-
clone
Description copied from class:ObjectCreates and returns a copy of thisObject. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should callsuper.clone()to create the new instance and then create deep copies of the nested, mutable objects. -
equals
Compares this object with the specified object and indicates if they are equal.- Overrides:
equalsin classObject- Parameters:
object- the object to compare with this object.- Returns:
trueifobjectis an instance ofDateFormatSymbolsand has the same symbols as this object,falseotherwise.- See Also:
hashCode()
-
toString
Description copied from class:ObjectReturns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toStringmethod if you intend implementing your owntoStringmethod. -
getAmPmStrings
Returns the array of strings which represent AM and PM. Use theCalendarconstantsCalendar.AMandCalendar.PMas indices for the array.- Returns:
- an array of strings.
-
getEras
Returns the array of strings which represent BC and AD. Use theCalendarconstantsGregorianCalendar.BCandGregorianCalendar.ADas indices for the array.- Returns:
- an array of strings.
-
getLocalPatternChars
Returns the pattern characters used bySimpleDateFormatto specify date and time fields.- Returns:
- a string containing the pattern characters.
-
getMonths
Returns the array of strings containing the full names of the months. Use theCalendarconstantsCalendar.JANUARYetc. as indices for the array.- Returns:
- an array of strings.
-
getShortMonths
Returns the array of strings containing the abbreviated names of the months. Use theCalendarconstantsCalendar.JANUARYetc. as indices for the array.- Returns:
- an array of strings.
-
getShortWeekdays
Returns the array of strings containing the abbreviated names of the days of the week. Use theCalendarconstantsCalendar.SUNDAYetc. as indices for the array.- Returns:
- an array of strings.
-
getWeekdays
Returns the array of strings containing the full names of the days of the week. Use theCalendarconstantsCalendar.SUNDAYetc. as indices for the array.- Returns:
- an array of strings.
-
getZoneStrings
Returns the two-dimensional array of strings containing localized names for time zones. Each row is an array of five strings:- The time zone ID, for example "America/Los_Angeles". This is not localized, and is used as a key into the table.
- The long display name, for example "Pacific Standard Time".
- The short display name, for example "PST".
- The long display name for DST, for example "Pacific Daylight Time". This is the non-DST long name for zones that have never had DST, for example "Central Standard Time" for "Canada/Saskatchewan".
- The short display name for DST, for example "PDT". This is the non-DST short name for zones that have never had DST, for example "CST" for "Canada/Saskatchewan".
-
hashCode
public int hashCode()Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually override both methods or neither method.Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
setAmPmStrings
Sets the array of strings which represent AM and PM. Use theCalendarconstantsCalendar.AMandCalendar.PMas indices for the array.- Parameters:
data- the array of strings for AM and PM.
-
setEras
Sets the array of Strings which represent BC and AD. Use theCalendarconstantsGregorianCalendar.BCandGregorianCalendar.ADas indices for the array.- Parameters:
data- the array of strings for BC and AD.
-
setLocalPatternChars
Sets the pattern characters used bySimpleDateFormatto specify date and time fields.- Parameters:
data- the string containing the pattern characters.- Throws:
NullPointerException- ifdatais null
-
setMonths
Sets the array of strings containing the full names of the months. Use theCalendarconstantsCalendar.JANUARYetc. as indices for the array.- Parameters:
data- the array of strings.
-
setShortMonths
Sets the array of strings containing the abbreviated names of the months. Use theCalendarconstantsCalendar.JANUARYetc. as indices for the array.- Parameters:
data- the array of strings.
-
setShortWeekdays
Sets the array of strings containing the abbreviated names of the days of the week. Use theCalendarconstantsCalendar.SUNDAYetc. as indices for the array.- Parameters:
data- the array of strings.
-
setWeekdays
Sets the array of strings containing the full names of the days of the week. Use theCalendarconstantsCalendar.SUNDAYetc. as indices for the array.- Parameters:
data- the array of strings.
-
setZoneStrings
Sets the two-dimensional array of strings containing localized names for time zones. SeegetZoneStrings()for details.- Throws:
IllegalArgumentException- if any row has fewer than 5 elements.NullPointerException- ifzoneStrings == null.
-