org.cip4.jdflib.util
Class NumberFormatter

java.lang.Object
  extended by org.cip4.jdflib.util.NumberFormatter

public class NumberFormatter
extends Object

class to format integers, longs, doubles etc.

Author:
Rainer Prosi, Heidelberger Druckmaschinen *

Constructor Summary
NumberFormatter()
          set up the defaults
 
Method Summary
 String formatDouble(double d)
          returns a formatted double.
 String formatDouble(double d, int precision)
          returns a formatted double.
 String formatInt(int i, int length)
          returns a formatted double.
 void setZapp0(boolean zapp0)
          if set, remove trailing 0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberFormatter

public NumberFormatter()
set up the defaults

Method Detail

setZapp0

public void setZapp0(boolean zapp0)
if set, remove trailing 0

Parameters:
zapp0 -

formatInt

public String formatInt(int i,
                        int length)
returns a formatted double. Truncates to exactly precision digits after the "."
If precision=0, the . is stripped

Parameters:
i - the integer to format
length - maximum precision, depending on value of zapp0, leading 0s are discarded or kept
Returns:
the formatted string that represents the integer

formatDouble

public 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 format
precision - maximum precision, depending on value of zapp0, trailing 0s are discarded or kept
Returns:
the formatted string that represents d TBD handle exp format

formatDouble

public 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


Copyright © 2013. All Rights Reserved.