Package org.cip4.jdflib.util
Class NumberFormatter
java.lang.Object
org.cip4.jdflib.util.NumberFormatter
class to format integers, longs, doubles etc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformatDouble(double d) returns a formatted double.formatDouble(double d, int precision) returns a formatted double.formatInt(int i, int length) returns a formatted integer with length digitsvoidsetZapp0(boolean zapp0) if set, remove trailing 0
-
Constructor Details
-
NumberFormatter
public NumberFormatter()set up the defaults
-
-
Method Details
-
setZapp0
public void setZapp0(boolean zapp0) if set, remove trailing 0- Parameters:
zapp0-
-
formatInt
returns a formatted integer with length digits- Parameters:
i- the integer to formatlength- total length of including leading zeros- Returns:
- the formatted string that represents the integer
-
formatDouble
returns a formatted double. Truncates to at most precision digits after the "."
If precision=0, the . is stripped- Parameters:
d- the double to formatprecision- maximum precision, depending on value of zapp0, trailing 0s are discarded or kept- Returns:
- the formatted string that represents d TBD handle exp format, null if NaN
-
formatDouble
returns a formatted double. Truncates to 8 digits after the "."
If the double is representable as an integer, any ".0" is stripped.- Parameters:
d- the double to format- Returns:
- the formatted string that represents d TBD handle exp format
-