Modifier and Type | Field and Description |
---|---|
static NumberFormat |
MACHINE_NO_DECIMAL_PLACES
Describes a format which rounds to integer numbers (no decimal places).
|
static NumberFormat |
MACHINE_TWO_DECIMAL_PLACES
Describes a format which rounds to two decimal places.
|
static NumberFormat |
NO_DECIMAL_PLACES
Describes a format which rounds to integer numbers (no decimal places).
|
static NumberFormat |
PERCENT
Describes the default format used to create string representations of percentages.
|
static NumberFormat |
TWO_DECIMAL_PLACES
Describes a format which rounds to two decimal places.
|
Constructor and Description |
---|
NumberFormat(int scale,
RoundingMode roundingMode,
DecimalFormatSymbols formatSymbols,
boolean useGrouping,
String suffix)
Creates a new number format used to format
amounts . |
Modifier and Type | Method and Description |
---|---|
DecimalFormatSymbols |
getDecimalFormatSymbols()
Returns the utilized format symbols when creating a string representation.
|
RoundingMode |
getRoundingMode()
Determines the rounding mode if more decimal places are available.
|
int |
getScale()
Returns the desired number of decimal places.
|
String |
getSuffix()
Returns the suffix appended to a formatted string, like a % sign.
|
boolean |
isUseGrouping()
Determines if grouping separaters (by thousands) should be placed or not.
|
public static final NumberFormat PERCENT
It therefore specifies two decimal places which are rounded RoundingMode.HALF_UP
. It uses
the decimal format symbols for the currently active language provided by
NLS
. As suffix the percent sign % is used.
NLS.getDecimalFormatSymbols()
public static final NumberFormat TWO_DECIMAL_PLACES
It specifies RoundingMode.HALF_UP
as rounding mode and uses
the decimal format symbols for the currently active language provided by
NLS
.
NLS.getDecimalFormatSymbols()
public static final NumberFormat MACHINE_TWO_DECIMAL_PLACES
It specifies RoundingMode.HALF_UP
as rounding mode and uses
the decimal format symbols for machine formats, provided by
NLS
.
NLS.getMachineFormatSymbols()
public static final NumberFormat NO_DECIMAL_PLACES
It specifies RoundingMode.HALF_UP
as rounding mode and uses
the decimal format symbols for the currently active language provided by
NLS
.
NLS.getDecimalFormatSymbols()
public static final NumberFormat MACHINE_NO_DECIMAL_PLACES
It specifies RoundingMode.HALF_UP
as rounding mode and uses
the decimal format symbols for machine formats, provided by
NLS
.
NLS.getMachineFormatSymbols()
public NumberFormat(int scale, @Nonnull RoundingMode roundingMode, @Nullable DecimalFormatSymbols formatSymbols, boolean useGrouping, @Nullable String suffix)
amounts
.scale
- contains the number of decimal places shown. Use Amount.toSmartRoundedString(NumberFormat)
to remove unwanted zeros.roundingMode
- contains the rounding mode to use. Most commonly RoundingMode.HALF_UP
will be
correct.formatSymbols
- contains the DecimalFormatSymbols
to use. This parameter can be null to
use the format symbols of the current language, which is present, when this format is used.useGrouping
- determines if grouping (by thousands) is used.suffix
- the suffix to append to a formatted stringpublic String getSuffix()
public int getScale()
public RoundingMode getRoundingMode()
public DecimalFormatSymbols getDecimalFormatSymbols()
public boolean isUseGrouping()
Copyright © 2018. All rights reserved.