APIdia Launch Partner
Top Description Fields Constructors Methods
java.time.format

public final Class DecimalStyle

extends Object
Class Inheritance
Imports
java.text.DecimalFormatSymbols, java.util.Collections, .HashSet, .Locale, .Objects, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap

Localized decimal style 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.

Implementation Specification

This class is immutable and thread-safe.

Since
1.8

Field Summary

Modifier and TypeField and Description
private static final ConcurrentMap<Locale, DecimalStyle>
CACHE

The cache of DecimalStyle instances.

private final char
decimalSeparator

The decimal separator.

private final char
negativeSign

The negative sign.

private final char
positiveSign

The positive sign.

public static final DecimalStyle
STANDARD

The standard set of non-localized decimal style symbols.

private final char
zeroDigit

The zero digit.

Constructor Summary

AccessConstructor and Description
private
DecimalStyle(char
the character to use for the digit of zero
zeroChar
,
char
the character to use for the positive sign
positiveSignChar
,
char
the character to use for the negative sign
negativeSignChar
,
char
the character to use for the decimal point
decimalPointChar
)

Restricted constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Returns:

the internationalized text, not null
convertNumberToI18N
(String
the text, consisting of digits 0 to 9, to convert, not null
numericText
)

Converts the input numeric text to the internationalized form using the zero character.

pack-priv int

Returns:

the value, 0 to 9, of the character, or -1 if not a digit
convertToDigit
(char
the character to check
ch
)

Checks whether the character is a digit, based on the currently set zero character.

private static DecimalStyle
create(Locale locale)

public boolean

Returns:

true if this is equal to the other date
equals
(Object
the object to check, null returns false
obj
)

Overrides java.lang.Object.equals.

Checks if this DecimalStyle is equal to another DecimalStyle.

public static Set<Locale>

Returns:

a Set of Locales for which localization is supported
getAvailableLocales
()

Lists all the locales that are supported.

public char

Returns:

the character for the decimal point
getDecimalSeparator
()

Gets the character that represents the decimal point.

public char

Returns:

the character for the negative sign
getNegativeSign
()

Gets the character that represents the negative sign.

public char

Returns:

the character for the positive sign
getPositiveSign
()

Gets the character that represents the positive sign.

public char

Returns:

the character for zero
getZeroDigit
()

Gets the character that represents zero.

public int

Returns:

a suitable hash code
hashCode
()

Overrides java.lang.Object.hashCode.

A hash code for this DecimalStyle.

public static DecimalStyle

Returns:

the decimal style, not null
of
(Locale
the locale, not null
locale
)

Obtains the DecimalStyle for the specified locale.

public static DecimalStyle

Returns:

the decimal style, not null
ofDefaultLocale
()

Obtains the DecimalStyle for the default FORMAT locale.

public String

Returns:

a string description, not null
toString
()

Overrides java.lang.Object.toString.

Returns a string describing this DecimalStyle.

public DecimalStyle

Returns:

a copy with a new character that represents the decimal point, not null
withDecimalSeparator
(char
the character for the decimal point
decimalSeparator
)

Returns a copy of the info with a new character that represents the decimal point.

public DecimalStyle

Returns:

a copy with a new character that represents the negative sign, not null
withNegativeSign
(char
the character for the negative sign
negativeSign
)

Returns a copy of the info with a new character that represents the negative sign.

public DecimalStyle

Returns:

a copy with a new character that represents the positive sign, not null
withPositiveSign
(char
the character for the positive sign
positiveSign
)

Returns a copy of the info with a new character that represents the positive sign.

public DecimalStyle

Returns:

a copy with a new character that represents zero, not null
withZeroDigit
(char
the character for zero
zeroDigit
)

Returns a copy of the info with a new character that represents zero.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

CACHEback to summary
private static final ConcurrentMap<Locale, DecimalStyle> CACHE

The cache of DecimalStyle instances.

decimalSeparatorback to summary
private final char decimalSeparator

The decimal separator.

negativeSignback to summary
private final char negativeSign

The negative sign.

positiveSignback to summary
private final char positiveSign

The positive sign.

STANDARDback to summary
public static final DecimalStyle STANDARD

The standard set of non-localized decimal style symbols.

This uses standard ASCII characters for zero, positive, negative and a dot for the decimal point.

zeroDigitback to summary
private final char zeroDigit

The zero digit.

Constructor Detail

DecimalStyleback to summary
private DecimalStyle(char zeroChar, char positiveSignChar, char negativeSignChar, char decimalPointChar)

Restricted constructor.

Parameters
zeroChar:char

the character to use for the digit of zero

positiveSignChar:char

the character to use for the positive sign

negativeSignChar:char

the character to use for the negative sign

decimalPointChar:char

the character to use for the decimal point

Method Detail

convertNumberToI18Nback to summary
pack-priv String convertNumberToI18N(String numericText)

Converts the input numeric text to the internationalized form using the zero character.

Parameters
numericText:String

the text, consisting of digits 0 to 9, to convert, not null

Returns:String

the internationalized text, not null

convertToDigitback to summary
pack-priv int convertToDigit(char ch)

Checks whether the character is a digit, based on the currently set zero character.

Parameters
ch:char

the character to check

Returns:int

the value, 0 to 9, of the character, or -1 if not a digit

createback to summary
private static DecimalStyle create(Locale locale)
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Checks if this DecimalStyle is equal to another DecimalStyle.

Parameters
obj:Object

the object to check, null returns false

Returns:boolean

true if this is equal to the other date

Annotations
@Override
getAvailableLocalesback to summary
public static Set<Locale> getAvailableLocales()

Lists all the locales that are supported.

At a minimum, the returned Set must contain a Locale instance equal to Locale.ROOT and a Locale instance equal to Locale.US.

Returns:Set<Locale>

a Set of Locales for which localization is supported

getDecimalSeparatorback to summary
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:char

the character for the decimal point

getNegativeSignback to summary
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:char

the character for the negative sign

getPositiveSignback to summary
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:char

the character for the positive sign

getZeroDigitback to summary
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:char

the character for zero

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

A hash code for this DecimalStyle.

Returns:int

a suitable hash code

Annotations
@Override
ofback to summary
public static DecimalStyle of(Locale locale)

Obtains the DecimalStyle for the specified locale.

This method provides access to locale sensitive decimal style symbols. If the locale contains "nu" (Numbering System) and/or "rg" (Region Override) Unicode extensions, returned instance will reflect the values specified with those extensions. If both "nu" and "rg" are specified, the value from the "nu" extension supersedes the implicit one from the "rg" extension.

Parameters
locale:Locale

the locale, not null

Returns:DecimalStyle

the decimal style, not null

ofDefaultLocaleback to summary
public static DecimalStyle ofDefaultLocale()

Obtains the DecimalStyle for the default FORMAT locale.

This method provides access to locale sensitive decimal style symbols.

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

Returns:DecimalStyle

the decimal style, not null

See Also
java.util.Locale.Category#FORMAT
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string describing this DecimalStyle.

Returns:String

a string description, not null

Annotations
@Override
withDecimalSeparatorback to summary
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:char

the character for the decimal point

Returns:DecimalStyle

a copy with a new character that represents the decimal point, not null

withNegativeSignback to summary
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:char

the character for the negative sign

Returns:DecimalStyle

a copy with a new character that represents the negative sign, not null

withPositiveSignback to summary
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:char

the character for the positive sign

Returns:DecimalStyle

a copy with a new character that represents the positive sign, not null

withZeroDigitback to summary
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:char

the character for zero

Returns:DecimalStyle

a copy with a new character that represents zero, not null