The style contains a number of fields that may be configured based on the locale:
The style can be used in three basic ways.
localize manually and optionally adjust to set as required
null and let the locale in the
formatter to determine the style
This class is immutable and thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | absValue
Whether to use the absolute value instead of the signed value. |
| public static final MoneyAmountStyle | ASCII_DECIMAL_COMMA_GROUP3_DOT
A style that uses ASCII digits/negative sign, the decimal comma and groups large amounts in 3's using a dot. |
| public static final MoneyAmountStyle | ASCII_DECIMAL_COMMA_GROUP3_SPACE
A style that uses ASCII digits/negative sign, the decimal comma and groups large amounts in 3's using a space. |
| public static final MoneyAmountStyle | ASCII_DECIMAL_COMMA_NO_GROUPING
A style that uses ASCII digits/negative sign, the decimal point and no grouping of large amounts. |
| public static final MoneyAmountStyle | ASCII_DECIMAL_POINT_GROUP3_COMMA
A style that uses ASCII digits/negative sign, the decimal point and groups large amounts in 3's using a comma. |
| public static final MoneyAmountStyle | ASCII_DECIMAL_POINT_GROUP3_SPACE
A style that uses ASCII digits/negative sign, the decimal point and groups large amounts in 3's using a space. |
| public static final MoneyAmountStyle | ASCII_DECIMAL_POINT_NO_GROUPING
A style that uses ASCII digits/negative sign, the decimal point and no grouping of large amounts. |
| private final int | decimalPointCharacter
The character used for the decimal point. |
| private final int | extendedGroupingSize
The size of each group. |
| private final boolean | forceDecimalPoint
Whether to always require the decimal point to be visible. |
| private final int | groupingCharacter
The character used for grouping. |
| private final int | groupingSize
The size of each group. |
| private final GroupingStyle | groupingStyle
Whether to group or not. |
| private static final ConcurrentMap | LOCALIZED_CACHE
Cache of localized styles. |
| public static final MoneyAmountStyle | LOCALIZED_GROUPING
A style that will be filled in with localized values using the locale of the formatter. |
| public static final MoneyAmountStyle | LOCALIZED_NO_GROUPING
A style that will be filled in with localized values using the locale of the formatter. |
| private final int | negativeCharacter
The prefix string when the amount is negative. |
| private final int | positiveCharacter
The character representing the positive sign. |
| private static final long | serialVersionUID
Serialization version. |
| private final int | zeroCharacter
The character defining zero, and thus the numbers zero to nine. |
| Access | Constructor and Description |
|---|---|
| private | MoneyAmountStyle(int
the zero character zeroCharacter, int the positive sign positiveCharacter, int the negative sign negativeCharacter, int the decimal point character decimalPointCharacter, GroupingStyle the grouping style, not null groupingStyle, int the grouping character groupingCharacter, int the grouping size groupingSize, int the extended grouping size extendedGroupingSize, boolean whether to always use the decimal point character forceDecimalPoint, boolean true to output the absolute value rather than the signed value absValue)Constructor, creating a new monetary instance. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if equalthe other style, null returns false other)Overrides java. Compares this style with another. |
| public Character | Returns: the decimal point character, null if to be determined by localeGets the character used for the decimal point. |
| public Integer | Returns: the size of each group, null if to be determined by localeGets the size of each group, not typically used. |
| public Character | Returns: the grouping character, null if to be determined by localeGets the character used to separate groups, typically thousands. |
| public Integer | Returns: the size of each group, null if to be determined by localeGets the size of each group, typically 3 for thousands. |
| public GroupingStyle | |
| private static MoneyAmountStyle | Returns: the symbols, never nullthe locale)Locale used to get the correct DecimalFormatSymbolsGets the prototype localized style for the given locale. |
| public Character | Returns: the format for negative amounts, null if to be determined by localeGets the character used for the negative sign character. |
| public Character | Returns: the format for positive amounts, null if to be determined by localeGets the character used for the positive sign character. |
| public Character | Returns: the zero character, null if to be determined by localeGets the character used for zero, and defining the characters zero to nine. |
| public int | |
| public boolean | Returns: true to output the absolute value, false for the signed valueReturns true if the absolute value setting. |
| public boolean | Returns: whether to force the decimal point on outputGets whether to always use the decimal point, even if there is no fraction. |
| public MoneyAmountStyle | |
| public static MoneyAmountStyle | |
| public String | Returns: a string summarising the style, never nullOverrides java. Gets a string summary of the style. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nulltrue to output the absolute value, false for the signed value absValue)Returns a copy of this style with the specified absolute value setting. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nullthe decimal point character, null if to be determined by locale decimalPointCharacter)Returns a copy of this style with the specified decimal point character. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nullthe size of each group, such as 3 for thousands,
not zero or negative, null if to be determined by locale extendedGroupingSize)Returns a copy of this style with the specified extended grouping size. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nulltrue to force the use of the decimal point, false to use it if required forceDecimalPoint)Returns a copy of this style with the specified decimal point setting. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nullthe grouping character, null if to be determined by locale groupingCharacter)Returns a copy of this style with the specified grouping character. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nullthe size of each group, such as 3 for thousands,
not zero or negative, null if to be determined by locale groupingSize)Returns a copy of this style with the specified grouping size. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nullthe grouping style, not null groupingStyle)Returns a copy of this style with the specified grouping setting. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nullthe negative character, null if to be determined by locale negativeCharacter)Returns a copy of this style with the specified negative sign character. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nullthe positive character, null if to be determined by locale positiveCharacter)Returns a copy of this style with the specified positive sign character. |
| public MoneyAmountStyle | Returns: the new instance for chaining, never nullthe zero character, null if to be determined by locale zeroCharacter)Returns a copy of this style with the specified zero character. |
| absValue | back to summary |
|---|---|
| private final boolean absValue Whether to use the absolute value instead of the signed value. | |
| ASCII_DECIMAL_COMMA_GROUP3_DOT | back to summary |
|---|---|
| public static final MoneyAmountStyle ASCII_DECIMAL_COMMA_GROUP3_DOT A style that uses ASCII digits/negative sign, the decimal comma and groups large amounts in 3's using a dot. Forced decimal point is disabled. | |
| ASCII_DECIMAL_COMMA_GROUP3_SPACE | back to summary |
|---|---|
| public static final MoneyAmountStyle ASCII_DECIMAL_COMMA_GROUP3_SPACE A style that uses ASCII digits/negative sign, the decimal comma and groups large amounts in 3's using a space. Forced decimal point is disabled. | |
| ASCII_DECIMAL_COMMA_NO_GROUPING | back to summary |
|---|---|
| public static final MoneyAmountStyle ASCII_DECIMAL_COMMA_NO_GROUPING A style that uses ASCII digits/negative sign, the decimal point and no grouping of large amounts. Forced decimal point is disabled. | |
| ASCII_DECIMAL_POINT_GROUP3_COMMA | back to summary |
|---|---|
| public static final MoneyAmountStyle ASCII_DECIMAL_POINT_GROUP3_COMMA A style that uses ASCII digits/negative sign, the decimal point and groups large amounts in 3's using a comma. Forced decimal point is disabled. | |
| ASCII_DECIMAL_POINT_GROUP3_SPACE | back to summary |
|---|---|
| public static final MoneyAmountStyle ASCII_DECIMAL_POINT_GROUP3_SPACE A style that uses ASCII digits/negative sign, the decimal point and groups large amounts in 3's using a space. Forced decimal point is disabled. | |
| ASCII_DECIMAL_POINT_NO_GROUPING | back to summary |
|---|---|
| public static final MoneyAmountStyle ASCII_DECIMAL_POINT_NO_GROUPING A style that uses ASCII digits/negative sign, the decimal point and no grouping of large amounts. Forced decimal point is disabled. | |
| decimalPointCharacter | back to summary |
|---|---|
| private final int decimalPointCharacter The character used for the decimal point. | |
| extendedGroupingSize | back to summary |
|---|---|
| private final int extendedGroupingSize The size of each group. | |
| forceDecimalPoint | back to summary |
|---|---|
| private final boolean forceDecimalPoint Whether to always require the decimal point to be visible. | |
| groupingCharacter | back to summary |
|---|---|
| private final int groupingCharacter The character used for grouping. | |
| groupingSize | back to summary |
|---|---|
| private final int groupingSize The size of each group. | |
| groupingStyle | back to summary |
|---|---|
| private final GroupingStyle groupingStyle Whether to group or not. | |
| LOCALIZED_CACHE | back to summary |
|---|---|
| private static final ConcurrentMap<Locale, MoneyAmountStyle> LOCALIZED_CACHE Cache of localized styles. | |
| LOCALIZED_GROUPING | back to summary |
|---|---|
| public static final MoneyAmountStyle LOCALIZED_GROUPING A style that will be filled in with localized values using the locale of the formatter. Grouping is enabled. Forced decimal point is disabled. | |
| LOCALIZED_NO_GROUPING | back to summary |
|---|---|
| public static final MoneyAmountStyle LOCALIZED_NO_GROUPING A style that will be filled in with localized values using the locale of the formatter. Grouping is disabled. Forced decimal point is disabled. | |
| negativeCharacter | back to summary |
|---|---|
| private final int negativeCharacter The prefix string when the amount is negative. | |
| positiveCharacter | back to summary |
|---|---|
| private final int positiveCharacter The character representing the positive sign. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version. | |
| zeroCharacter | back to summary |
|---|---|
| private final int zeroCharacter The character defining zero, and thus the numbers zero to nine. | |
| MoneyAmountStyle | back to summary |
|---|---|
| private MoneyAmountStyle(int zeroCharacter, int positiveCharacter, int negativeCharacter, int decimalPointCharacter, GroupingStyle groupingStyle, int groupingCharacter, int groupingSize, int extendedGroupingSize, boolean forceDecimalPoint, boolean absValue) Constructor, creating a new monetary instance.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Compares this style with another. | |
| getDecimalPointCharacter | back to summary |
|---|---|
| public Character getDecimalPointCharacter() Gets the character used for the decimal point.
| |
| getExtendedGroupingSize | back to summary |
|---|---|
| public Integer getExtendedGroupingSize() Gets the size of each group, not typically used. This is primarily used to enable the Indian Number System, where the group closest to the decimal point is of size 3 and other groups are of size 2. The extended grouping size is used for groups that are not next to the decimal point. The value zero is used to indicate that extended grouping is not needed.
| |
| getGroupingCharacter | back to summary |
|---|---|
| public Character getGroupingCharacter() Gets the character used to separate groups, typically thousands.
| |
| getGroupingSize | back to summary |
|---|---|
| public Integer getGroupingSize() Gets the size of each group, typically 3 for thousands.
| |
| getGroupingStyle | back to summary |
|---|---|
| public GroupingStyle getGroupingStyle() Gets the style of grouping required.
| |
| getLocalizedStyle | back to summary |
|---|---|
| private static MoneyAmountStyle getLocalizedStyle(Locale locale) Gets the prototype localized style for the given locale.
This uses
The method
| |
| getNegativeSignCharacter | back to summary |
|---|---|
| public Character getNegativeSignCharacter() Gets the character used for the negative sign character. The standard ASCII symbol is '-'.
| |
| getPositiveSignCharacter | back to summary |
|---|---|
| public Character getPositiveSignCharacter() Gets the character used for the positive sign character. The standard ASCII symbol is '+'.
| |
| getZeroCharacter | back to summary |
|---|---|
| public Character getZeroCharacter() Gets the character used for zero, and defining the characters zero to nine. The UTF-8 standard supports a number of different numeric scripts. Each script has the characters in order from zero to nine. This method returns the zero character, which therefore also defines one to nine.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. A suitable hash code.
| |
| isAbsValue | back to summary |
|---|---|
| public boolean isAbsValue() Returns true if the absolute value setting. If this is set to true, the absolute (unsigned) value will be output. If this is set to false, the signed value will be output. Note that when parsing, signs are accepted.
| |
| isForcedDecimalPoint | back to summary |
|---|---|
| public boolean isForcedDecimalPoint() Gets whether to always use the decimal point, even if there is no fraction.
| |
| localize | back to summary |
|---|---|
| public MoneyAmountStyle localize(Locale locale) Returns a
This method will return a new instance where each field that was defined
to be localized (by being set to
The settings for the locale are pulled from
| |
| of | back to summary |
|---|---|
| public static MoneyAmountStyle of(Locale locale) Gets a localized style. This creates a localized style for the specified locale. Grouping will be enabled, forced decimal point will be disabled, absolute values will be disabled.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Gets a string summary of the style. | |
| withAbsValue | back to summary |
|---|---|
| public MoneyAmountStyle withAbsValue(boolean absValue) Returns a copy of this style with the specified absolute value setting. If this is set to true, the absolute (unsigned) value will be output. If this is set to false, the signed value will be output. Note that when parsing, signs are accepted.
| |
| withDecimalPointCharacter | back to summary |
|---|---|
| public MoneyAmountStyle withDecimalPointCharacter(Character decimalPointCharacter) Returns a copy of this style with the specified decimal point character. For English, this is a dot.
| |
| withExtendedGroupingSize | back to summary |
|---|---|
| public MoneyAmountStyle withExtendedGroupingSize(Integer extendedGroupingSize) Returns a copy of this style with the specified extended grouping size.
| |
| withForcedDecimalPoint | back to summary |
|---|---|
| public MoneyAmountStyle withForcedDecimalPoint(boolean forceDecimalPoint) Returns a copy of this style with the specified decimal point setting.
| |
| withGroupingCharacter | back to summary |
|---|---|
| public MoneyAmountStyle withGroupingCharacter(Character groupingCharacter) Returns a copy of this style with the specified grouping character. For English, this is a comma.
| |
| withGroupingSize | back to summary |
|---|---|
| public MoneyAmountStyle withGroupingSize(Integer groupingSize) Returns a copy of this style with the specified grouping size.
| |
| withGroupingStyle | back to summary |
|---|---|
| public MoneyAmountStyle withGroupingStyle(GroupingStyle groupingStyle) Returns a copy of this style with the specified grouping setting.
| |
| withNegativeSignCharacter | back to summary |
|---|---|
| public MoneyAmountStyle withNegativeSignCharacter(Character negativeCharacter) Returns a copy of this style with the specified negative sign character. The standard ASCII symbol is '-'.
| |
| withPositiveSignCharacter | back to summary |
|---|---|
| public MoneyAmountStyle withPositiveSignCharacter(Character positiveCharacter) Returns a copy of this style with the specified positive sign character. The standard ASCII symbol is '+'.
| |
| withZeroCharacter | back to summary |
|---|---|
| public MoneyAmountStyle withZeroCharacter(Character zeroCharacter) Returns a copy of this style with the specified zero character. The UTF-8 standard supports a number of different numeric scripts. Each script has the characters in order from zero to nine. This method sets the zero character, which therefore also defines one to nine. For English, this is a '0'. Some other scripts use different characters for the numbers zero to nine.
| |