|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.joda.money.format.MoneyAmountStyle
public final class MoneyAmountStyle
Defines the style that the amount of a monetary value will be formatted with.
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.
Field Summary | |
---|---|
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. |
Method Summary | |
---|---|
boolean |
equals(Object other)
Compares this style with another. |
Character |
getDecimalPointCharacter()
Gets the character used for the decimal point. |
Integer |
getExtendedGroupingSize()
Gets the size of each group, not typically used. |
Character |
getGroupingCharacter()
Gets the character used to separate groups, typically thousands. |
Integer |
getGroupingSize()
Gets the size of each group, typically 3 for thousands. |
GroupingStyle |
getGroupingStyle()
Gets the style of grouping required. |
Character |
getNegativeSignCharacter()
Gets the character used for the negative sign character. |
Character |
getPositiveSignCharacter()
Gets the character used for the positive sign character. |
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(Locale locale)
Returns a MoneyAmountStyle instance configured for the specified locale. |
static MoneyAmountStyle |
of(Locale locale)
Gets a localized style. |
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(Character decimalPointCharacter)
Returns a copy of this style with the specified decimal point character. |
MoneyAmountStyle |
withExtendedGroupingSize(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(Character groupingCharacter)
Returns a copy of this style with the specified grouping character. |
MoneyAmountStyle |
withGroupingSize(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(Character negativeCharacter)
Returns a copy of this style with the specified negative sign character. |
MoneyAmountStyle |
withPositiveSignCharacter(Character positiveCharacter)
Returns a copy of this style with the specified positive sign character. |
MoneyAmountStyle |
withZeroCharacter(Character zeroCharacter)
Returns a copy of this style with the specified zero character. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
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
Method Detail |
---|
public static MoneyAmountStyle of(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 null
public MoneyAmountStyle localize(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 null
public 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(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 locale
public Character getPositiveSignCharacter()
The standard ASCII symbol is '+'.
public MoneyAmountStyle withPositiveSignCharacter(Character positiveCharacter)
The standard ASCII symbol is '+'.
positiveCharacter
- the positive character, null if to be determined by locale
public Character getNegativeSignCharacter()
The standard ASCII symbol is '-'.
public MoneyAmountStyle withNegativeSignCharacter(Character negativeCharacter)
The standard ASCII symbol is '-'.
negativeCharacter
- the negative character, null if to be determined by locale
public Character getDecimalPointCharacter()
public MoneyAmountStyle withDecimalPointCharacter(Character decimalPointCharacter)
For English, this is a dot.
decimalPointCharacter
- the decimal point character, null if to be determined by locale
public Character getGroupingCharacter()
public MoneyAmountStyle withGroupingCharacter(Character groupingCharacter)
For English, this is a comma.
groupingCharacter
- the grouping character, null if to be determined by locale
public Integer getGroupingSize()
public MoneyAmountStyle withGroupingSize(Integer groupingSize)
groupingSize
- the size of each group, such as 3 for thousands,
not zero or negative, null if to be determined by locale
IllegalArgumentException
- if the grouping size is zero or lesspublic 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(Integer extendedGroupingSize)
extendedGroupingSize
- the size of each group, such as 3 for thousands,
not zero or negative, null if to be determined by locale
IllegalArgumentException
- if the grouping size is zero or lesspublic GroupingStyle getGroupingStyle()
public MoneyAmountStyle withGroupingStyle(GroupingStyle groupingStyle)
groupingStyle
- the grouping style, not null
public boolean isForcedDecimalPoint()
public MoneyAmountStyle withForcedDecimalPoint(boolean forceDecimalPoint)
forceDecimalPoint
- true to force the use of the decimal point, false to use it if required
public 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 value
public boolean equals(Object other)
equals
in class Object
other
- the other style, null returns false
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |