|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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. |
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 |
isForcedDecimalPoint()
Gets whether to always use the decimal point, even if there is no fraction. |
boolean |
isGrouping()
Deprecated. Use getGroupingStyle() |
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 |
withDecimalPointCharacter(Character decimalPointCharacter)
Returns a copy of this style with the specified decimal point character. |
MoneyAmountStyle |
withForcedDecimalPoint(boolean forceDecimalPoint)
Returns a copy of this style with the specified decimal point setting. |
MoneyAmountStyle |
withGrouping(boolean grouping)
Deprecated. Use withGroupingStyle(GroupingStyle.FULL) |
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.
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 less@Deprecated public boolean isGrouping()
@Deprecated public MoneyAmountStyle withGrouping(boolean grouping)
grouping
- true to use the grouping separator, false to not use it
public 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 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 |