Class NumberFormatter

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

public class NumberFormatter extends Object
class to format integers, longs, doubles etc.
  • 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

      public String formatInt(int i, int length)
      returns a formatted integer with length digits
      Parameters:
      i - the integer to format
      length - total length of including leading zeros
      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, null if NaN
    • 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