Package org.cip4.jdflib.util
Class NumberFormatter
- java.lang.Object
-
- org.cip4.jdflib.util.NumberFormatter
-
public class NumberFormatter extends java.lang.Objectclass to format integers, longs, doubles etc.
-
-
Constructor Summary
Constructors Constructor Description NumberFormatter()set up the defaults
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringformatDouble(double d)returns a formatted double.java.lang.StringformatDouble(double d, int precision)returns a formatted double.java.lang.StringformatInt(int i, int length)returns a formatted integer with length digitsvoidsetZapp0(boolean zapp0)if set, remove trailing 0
-
-
-
Method Detail
-
setZapp0
public void setZapp0(boolean zapp0)
if set, remove trailing 0- Parameters:
zapp0-
-
formatInt
public java.lang.String formatInt(int i, int length)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
public java.lang.String formatDouble(double d, int precision)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
public java.lang.String formatDouble(double d)
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
-
-