Class HMSNumberFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class HMSNumberFormat
    extends java.text.NumberFormat
    A custom number formatter that formats numbers (in seconds) as HH:MM:SS. Created in response to: http://stackoverflow.com/questions/19028908/jfreechart-need-to-customize-y-axis-just-for-printing
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.text.NumberFormat

        java.text.NumberFormat.Field
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.text.NumberFormat formatter  
      • Fields inherited from class java.text.NumberFormat

        FRACTION_FIELD, INTEGER_FIELD
    • Constructor Summary

      Constructors 
      Constructor Description
      HMSNumberFormat()
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.StringBuffer format​(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
      Formats the specified number as a string of the form HH:MM:SS.
      java.lang.StringBuffer format​(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
      Formats the specified number as a string of the form HH:MM:SS.
      java.lang.Number parse​(java.lang.String source, java.text.ParsePosition parsePosition)
      Parsing is not implemented, so this method always returns null.
      • Methods inherited from class java.text.NumberFormat

        clone, equals, format, format, format, getAvailableLocales, getCurrency, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, getRoundingMode, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly, setRoundingMode
      • Methods inherited from class java.text.Format

        format, formatToCharacterIterator, parseObject
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • formatter

        private java.text.NumberFormat formatter
    • Constructor Detail

      • HMSNumberFormat

        public HMSNumberFormat()
        Creates a new instance.
    • Method Detail

      • format

        public java.lang.StringBuffer format​(double number,
                                             java.lang.StringBuffer toAppendTo,
                                             java.text.FieldPosition pos)
        Formats the specified number as a string of the form HH:MM:SS. The decimal fraction is ignored.
        Specified by:
        format in class java.text.NumberFormat
        Parameters:
        number - the number to format.
        toAppendTo - the buffer to append to (ignored here).
        pos - the field position (ignored here).
        Returns:
        The string buffer.
      • format

        public java.lang.StringBuffer format​(long number,
                                             java.lang.StringBuffer toAppendTo,
                                             java.text.FieldPosition pos)
        Formats the specified number as a string of the form HH:MM:SS.
        Specified by:
        format in class java.text.NumberFormat
        Parameters:
        number - the number to format.
        toAppendTo - the buffer to append to (ignored here).
        pos - the field position (ignored here).
        Returns:
        The string buffer.
      • parse

        public java.lang.Number parse​(java.lang.String source,
                                      java.text.ParsePosition parsePosition)
        Parsing is not implemented, so this method always returns null.
        Specified by:
        parse in class java.text.NumberFormat
        Parameters:
        source - ignored.
        parsePosition - ignored.
        Returns:
        Always null.