Class DecimalStyle
- java.lang.Object
-
- org.threeten.bp.format.DecimalStyle
-
public final class DecimalStyle extends java.lang.ObjectLocalized symbols used in date and time formatting.A significant part of dealing with dates and times is the localization. This class acts as a central point for accessing the information.
Specification for implementors
This class is immutable and thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.ConcurrentMap<java.util.Locale,DecimalStyle>CACHEThe cache of symbols instances.private chardecimalSeparatorThe decimal separator.private charnegativeSignThe negative sign.private charpositiveSignThe positive sign.static DecimalStyleSTANDARDThe standard set of non-localized symbols.private charzeroDigitThe zero digit.
-
Constructor Summary
Constructors Modifier Constructor Description privateDecimalStyle(char zeroChar, char positiveSignChar, char negativeSignChar, char decimalPointChar)Restricted constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.lang.StringconvertNumberToI18N(java.lang.String numericText)Converts the input numeric text to the internationalized form using the zero character.(package private) intconvertToDigit(char ch)Checks whether the character is a digit, based on the currently set zero character.private static DecimalStylecreate(java.util.Locale locale)booleanequals(java.lang.Object obj)Checks if these symbols equal another set of symbols.static java.util.Set<java.util.Locale>getAvailableLocales()Lists all the locales that are supported.chargetDecimalSeparator()Gets the character that represents the decimal point.chargetNegativeSign()Gets the character that represents the negative sign.chargetPositiveSign()Gets the character that represents the positive sign.chargetZeroDigit()Gets the character that represents zero.inthashCode()A hash code for these symbols.static DecimalStyleof(java.util.Locale locale)Obtains symbols for the specified locale.static DecimalStyleofDefaultLocale()Obtains symbols for the default locale.java.lang.StringtoString()Returns a string describing these symbols.DecimalStylewithDecimalSeparator(char decimalSeparator)Returns a copy of the info with a new character that represents the decimal point.DecimalStylewithNegativeSign(char negativeSign)Returns a copy of the info with a new character that represents the negative sign.DecimalStylewithPositiveSign(char positiveSign)Returns a copy of the info with a new character that represents the positive sign.DecimalStylewithZeroDigit(char zeroDigit)Returns a copy of the info with a new character that represents zero.
-
-
-
Field Detail
-
STANDARD
public static final DecimalStyle STANDARD
The standard set of non-localized symbols.This uses standard ASCII characters for zero, positive, negative and a dot for the decimal point.
-
CACHE
private static final java.util.concurrent.ConcurrentMap<java.util.Locale,DecimalStyle> CACHE
The cache of symbols instances.
-
zeroDigit
private final char zeroDigit
The zero digit.
-
positiveSign
private final char positiveSign
The positive sign.
-
negativeSign
private final char negativeSign
The negative sign.
-
decimalSeparator
private final char decimalSeparator
The decimal separator.
-
-
Constructor Detail
-
DecimalStyle
private DecimalStyle(char zeroChar, char positiveSignChar, char negativeSignChar, char decimalPointChar)Restricted constructor.- Parameters:
zeroChar- the character to use for the digit of zeropositiveSignChar- the character to use for the positive signnegativeSignChar- the character to use for the negative signdecimalPointChar- the character to use for the decimal point
-
-
Method Detail
-
getAvailableLocales
public static java.util.Set<java.util.Locale> getAvailableLocales()
Lists all the locales that are supported.The locale 'en_US' will always be present.
- Returns:
- an array of locales for which localization is supported
-
ofDefaultLocale
public static DecimalStyle ofDefaultLocale()
Obtains symbols for the default locale.This method provides access to locale sensitive symbols.
- Returns:
- the info, not null
-
of
public static DecimalStyle of(java.util.Locale locale)
Obtains symbols for the specified locale.This method provides access to locale sensitive symbols.
- Parameters:
locale- the locale, not null- Returns:
- the info, not null
-
create
private static DecimalStyle create(java.util.Locale locale)
-
getZeroDigit
public char getZeroDigit()
Gets the character that represents zero.The character used to represent digits may vary by culture. This method specifies the zero character to use, which implies the characters for one to nine.
- Returns:
- the character for zero
-
withZeroDigit
public DecimalStyle withZeroDigit(char zeroDigit)
Returns a copy of the info with a new character that represents zero.The character used to represent digits may vary by culture. This method specifies the zero character to use, which implies the characters for one to nine.
- Parameters:
zeroDigit- the character for zero- Returns:
- a copy with a new character that represents zero, not null
-
getPositiveSign
public char getPositiveSign()
Gets the character that represents the positive sign.The character used to represent a positive number may vary by culture. This method specifies the character to use.
- Returns:
- the character for the positive sign
-
withPositiveSign
public DecimalStyle withPositiveSign(char positiveSign)
Returns a copy of the info with a new character that represents the positive sign.The character used to represent a positive number may vary by culture. This method specifies the character to use.
- Parameters:
positiveSign- the character for the positive sign- Returns:
- a copy with a new character that represents the positive sign, not null
-
getNegativeSign
public char getNegativeSign()
Gets the character that represents the negative sign.The character used to represent a negative number may vary by culture. This method specifies the character to use.
- Returns:
- the character for the negative sign
-
withNegativeSign
public DecimalStyle withNegativeSign(char negativeSign)
Returns a copy of the info with a new character that represents the negative sign.The character used to represent a negative number may vary by culture. This method specifies the character to use.
- Parameters:
negativeSign- the character for the negative sign- Returns:
- a copy with a new character that represents the negative sign, not null
-
getDecimalSeparator
public char getDecimalSeparator()
Gets the character that represents the decimal point.The character used to represent a decimal point may vary by culture. This method specifies the character to use.
- Returns:
- the character for the decimal point
-
withDecimalSeparator
public DecimalStyle withDecimalSeparator(char decimalSeparator)
Returns a copy of the info with a new character that represents the decimal point.The character used to represent a decimal point may vary by culture. This method specifies the character to use.
- Parameters:
decimalSeparator- the character for the decimal point- Returns:
- a copy with a new character that represents the decimal point, not null
-
convertToDigit
int convertToDigit(char ch)
Checks whether the character is a digit, based on the currently set zero character.- Parameters:
ch- the character to check- Returns:
- the value, 0 to 9, of the character, or -1 if not a digit
-
convertNumberToI18N
java.lang.String convertNumberToI18N(java.lang.String numericText)
Converts the input numeric text to the internationalized form using the zero character.- Parameters:
numericText- the text, consisting of digits 0 to 9, to convert, not null- Returns:
- the internationalized text, not null
-
equals
public boolean equals(java.lang.Object obj)
Checks if these symbols equal another set of symbols.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to check, null returns false- Returns:
- true if this is equal to the other date
-
hashCode
public int hashCode()
A hash code for these symbols.- Overrides:
hashCodein classjava.lang.Object- Returns:
- a suitable hash code
-
toString
public java.lang.String toString()
Returns a string describing these symbols.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string description, not null
-
-