java.io.Serializablepublic final class MoneyAmountStyle
extends java.lang.Object
implements java.io.Serializable
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(java.util.Locale) 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 | Description |
|---|---|---|
static 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.
|
static 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.
|
static MoneyAmountStyle |
ASCII_DECIMAL_COMMA_NO_GROUPING |
A style that uses ASCII digits/negative sign, the decimal point
and no grouping of large amounts.
|
static 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.
|
static 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.
|
static MoneyAmountStyle |
ASCII_DECIMAL_POINT_NO_GROUPING |
A style that uses ASCII digits/negative sign, the decimal point
and no grouping of large amounts.
|
static MoneyAmountStyle |
LOCALIZED_GROUPING |
A style that will be filled in with localized values using the locale of the formatter.
|
static MoneyAmountStyle |
LOCALIZED_NO_GROUPING |
A style that will be filled in with localized values using the locale of the formatter.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals(java.lang.Object other) |
Compares this style with another.
|
java.lang.Character |
getDecimalPointCharacter() |
Gets the character used for the decimal point.
|
java.lang.Integer |
getExtendedGroupingSize() |
Gets the size of each group, not typically used.
|
java.lang.Character |
getGroupingCharacter() |
Gets the character used to separate groups, typically thousands.
|
java.lang.Integer |
getGroupingSize() |
Gets the size of each group, typically 3 for thousands.
|
GroupingStyle |
getGroupingStyle() |
Gets the style of grouping required.
|
java.lang.Character |
getNegativeSignCharacter() |
Gets the character used for the negative sign character.
|
java.lang.Character |
getPositiveSignCharacter() |
Gets the character used for the positive sign character.
|
java.lang.Character |
getZeroCharacter() |
Gets the character used for zero, and defining the characters zero to nine.
|
int |
hashCode() |
A suitable hash code.
|
boolean |
isAbsValue() |
Returns true if the absolute value setting.
|
boolean |
isForcedDecimalPoint() |
Gets whether to always use the decimal point, even if there is no fraction.
|
MoneyAmountStyle |
localize(java.util.Locale locale) |
Returns a
MoneyAmountStyle instance configured for the specified locale. |
static MoneyAmountStyle |
of(java.util.Locale locale) |
Gets a localized style.
|
java.lang.String |
toString() |
Gets a string summary of the style.
|
MoneyAmountStyle |
withAbsValue(boolean absValue) |
Returns a copy of this style with the specified absolute value setting.
|
MoneyAmountStyle |
withDecimalPointCharacter(java.lang.Character decimalPointCharacter) |
Returns a copy of this style with the specified decimal point character.
|
MoneyAmountStyle |
withExtendedGroupingSize(java.lang.Integer extendedGroupingSize) |
Returns a copy of this style with the specified extended grouping size.
|
MoneyAmountStyle |
withForcedDecimalPoint(boolean forceDecimalPoint) |
Returns a copy of this style with the specified decimal point setting.
|
MoneyAmountStyle |
withGroupingCharacter(java.lang.Character groupingCharacter) |
Returns a copy of this style with the specified grouping character.
|
MoneyAmountStyle |
withGroupingSize(java.lang.Integer groupingSize) |
Returns a copy of this style with the specified grouping size.
|
MoneyAmountStyle |
withGroupingStyle(GroupingStyle groupingStyle) |
Returns a copy of this style with the specified grouping setting.
|
MoneyAmountStyle |
withNegativeSignCharacter(java.lang.Character negativeCharacter) |
Returns a copy of this style with the specified negative sign character.
|
MoneyAmountStyle |
withPositiveSignCharacter(java.lang.Character positiveCharacter) |
Returns a copy of this style with the specified positive sign character.
|
MoneyAmountStyle |
withZeroCharacter(java.lang.Character zeroCharacter) |
Returns a copy of this style with the specified zero character.
|
public static final MoneyAmountStyle ASCII_DECIMAL_POINT_GROUP3_COMMA
public static final MoneyAmountStyle ASCII_DECIMAL_POINT_GROUP3_SPACE
public static final MoneyAmountStyle ASCII_DECIMAL_POINT_NO_GROUPING
public static final MoneyAmountStyle ASCII_DECIMAL_COMMA_GROUP3_DOT
public static final MoneyAmountStyle ASCII_DECIMAL_COMMA_GROUP3_SPACE
public static final MoneyAmountStyle ASCII_DECIMAL_COMMA_NO_GROUPING
public static final MoneyAmountStyle LOCALIZED_GROUPING
public static final MoneyAmountStyle LOCALIZED_NO_GROUPING
public static MoneyAmountStyle of(java.util.Locale locale)
This creates a localized style for the specified locale. Grouping will be enabled, forced decimal point will be disabled, absolute values will be disabled.
locale - the locale to use, not nullpublic MoneyAmountStyle localize(java.util.Locale locale)
MoneyAmountStyle instance configured for the specified locale.
This method will return a new instance where each field that was defined
to be localized (by being set to null) is filled in.
If this instance is fully defined (with all fields non-null), then this
method has no effect. Once this method is called, no method will return null.
The settings for the locale are pulled from DecimalFormatSymbols and
DecimalFormat.
locale - the locale to use, not nullpublic java.lang.Character getZeroCharacter()
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.
public MoneyAmountStyle withZeroCharacter(java.lang.Character zeroCharacter)
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.
zeroCharacter - the zero character, null if to be determined by localepublic java.lang.Character getPositiveSignCharacter()
The standard ASCII symbol is '+'.
public MoneyAmountStyle withPositiveSignCharacter(java.lang.Character positiveCharacter)
The standard ASCII symbol is '+'.
positiveCharacter - the positive character, null if to be determined by localepublic java.lang.Character getNegativeSignCharacter()
The standard ASCII symbol is '-'.
public MoneyAmountStyle withNegativeSignCharacter(java.lang.Character negativeCharacter)
The standard ASCII symbol is '-'.
negativeCharacter - the negative character, null if to be determined by localepublic java.lang.Character getDecimalPointCharacter()
public MoneyAmountStyle withDecimalPointCharacter(java.lang.Character decimalPointCharacter)
For English, this is a dot.
decimalPointCharacter - the decimal point character, null if to be determined by localepublic java.lang.Character getGroupingCharacter()
public MoneyAmountStyle withGroupingCharacter(java.lang.Character groupingCharacter)
For English, this is a comma.
groupingCharacter - the grouping character, null if to be determined by localepublic java.lang.Integer getGroupingSize()
public MoneyAmountStyle withGroupingSize(java.lang.Integer groupingSize)
groupingSize - the size of each group, such as 3 for thousands,
not zero or negative, null if to be determined by localejava.lang.IllegalArgumentException - if the grouping size is zero or lesspublic java.lang.Integer getExtendedGroupingSize()
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.
public MoneyAmountStyle withExtendedGroupingSize(java.lang.Integer extendedGroupingSize)
extendedGroupingSize - the size of each group, such as 3 for thousands,
not zero or negative, null if to be determined by localejava.lang.IllegalArgumentException - if the grouping size is zero or lesspublic GroupingStyle getGroupingStyle()
public MoneyAmountStyle withGroupingStyle(GroupingStyle groupingStyle)
groupingStyle - the grouping style, not nullpublic boolean isForcedDecimalPoint()
public MoneyAmountStyle withForcedDecimalPoint(boolean forceDecimalPoint)
forceDecimalPoint - true to force the use of the decimal point, false to use it if requiredpublic boolean isAbsValue()
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.
public MoneyAmountStyle withAbsValue(boolean absValue)
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.
absValue - true to output the absolute value, false for the signed valuepublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - the other style, null returns falsepublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2009–2018 Joda.org. All rights reserved.