DecimalFormat class
A minimal java.text.DecimalFormat for the number patterns MPAndroidChart uses, such as ###,###,###,##0.0,
###,###,###,##0, ###,###,##0.# and #.##.
Supported pattern characters: # (optional digit), 0 (required digit), , (grouping separator; the group size
is the number of digits after the last , of the integer part) and one . (decimal separator). The fraction part
is zero or more 0 followed by zero or more #. Prefixes, suffixes, percent, exponents and quotes are not
supported and throw an ArgumentError.
A double is rounded with RoundingMode.HALF_EVEN applied to its exact binary value, to the maximum number of
fraction digits (so #.## formats 1.005 as 1, since 1.005 is stored slightly below the tie, and 0.125 as 0.12);
the digits are its shortest round-trip decimal digits. The JDK and Android's ICU DecimalFormat each differ from
this, and from each other, on rare inputs next to a decimal tie (see MIGRATION.md). An int is formatted exactly, like Java's format(long). A negative value keeps its minus sign even when
it rounds to zero (#.# formats -0.01 as -0), and -0.0 prints -0. NaN prints NaN and the infinities ∞ and
-∞.
Unlike Java, the symbols are fixed (. decimal separator, , grouping separator, - minus sign) and never follow
the locale.
Constructors
- DecimalFormat(String pattern)
-
Creates a format for
pattern; throws an ArgumentError for a pattern outside the supported family.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- maximumFractionDigits → int
-
The maximum number of fraction digits shown (
DecimalFormat.getMaximumFractionDigits): all digits after..no setter - minimumFractionDigits → int
-
The minimum number of fraction digits shown (
DecimalFormat.getMinimumFractionDigits): the0s after..no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
format(
num value) → String -
Formats
valuewith this pattern. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited