Class Formatter

    • Constructor Detail

      • Formatter

        public Formatter​(Format format)
        Initializes the formatter.
        Parameters:
        format - the Java formatter to use
        See Also:
        setFormat(Format)
    • Method Detail

      • setFormat

        public void setFormat​(Format format)
        Sets the Java formatter to use. Only DecimalFormat and SimpleDateFormat are allowed.
        Parameters:
        format - the Java formatter to use
      • getFormat

        public Format getFormat()
        Returns in the Java formatter used internally.
        Returns:
        the formatter
      • applyPattern

        public void applyPattern​(String pattern)
        Applies the given pattern.
        Parameters:
        pattern - the pattern to use
      • toPattern

        public String toPattern()
        Returns the pattern in use by the Java formatter.
        Returns:
        the pattern in use
      • parse

        public Double parse​(String s)
        Parses the given string. Returns Double.NaN in case of an error.
        Parameters:
        s - the string to parse
        Returns:
        the value or Double.NaN in case of an error
      • format

        public String format​(Double value)
        Formats the given value and returns the string.
        Parameters:
        value - the value to turn into a string
        Returns:
        the generated string
      • getFormatter

        protected static Formatter getFormatter​(Format format,
                                                String pattern)
        Returns an instance of a decimal formatter with a specified pattern.
        Parameters:
        format - the Java formatter to use
        pattern - the pattern to use, ignored if null
        Returns:
        the formatter
      • toString

        public String toString()
        A string representation of the formatter.
        Overrides:
        toString in class Object
        Returns:
        a string representation
      • getDecimalFormatter

        public static Formatter getDecimalFormatter()
        Returns an instance of a decimal formatter.
        Returns:
        the formatter
      • getDecimalFormatter

        public static Formatter getDecimalFormatter​(String pattern)
        Returns an instance of a decimal formatter with a specified pattern.
        Parameters:
        pattern - the pattern to use, ignored if null
        Returns:
        the formatter
      • getDateFormatter

        public static Formatter getDateFormatter()
        Returns an instance of a date formatter.
        Returns:
        the formatter
      • getDateFormatter

        public static Formatter getDateFormatter​(String pattern)
        Returns an instance of a date formatter with a specified pattern.
        Parameters:
        pattern - the pattern to use, ignored if null
        Returns:
        the formatter