Package de.sciss.gui

Class TimeFormat

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

    public class TimeFormat
    extends java.text.MessageFormat
    A MessageFormat subclass for displaying time values in minutes and seconds.
    See Also:
    NumberField.HHMMSS, Serialized Form
    • Nested Class Summary

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

        java.text.MessageFormat.Field
    • Constructor Summary

      Constructors 
      Constructor Description
      TimeFormat​(int flags, java.lang.String prefix, java.lang.String suffix, int numDecimals, java.util.Locale locale)
      Constructs a new TimeFormat with automatically created pattern.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String formatTime​(java.lang.Number seconds)
      Creates a formatted string using a parameter for seconds synchronization: when called concurrently, explicit synchronization must be enforced
      java.lang.Number parseTime​(java.lang.String str)
      Tries to parse a formatted time string (as produced by formatTime).
      • Methods inherited from class java.text.MessageFormat

        applyPattern, clone, equals, format, format, format, formatToCharacterIterator, getFormats, getFormatsByArgumentIndex, getLocale, hashCode, parse, parse, parseObject, setFormat, setFormatByArgumentIndex, setFormats, setFormatsByArgumentIndex, setLocale, toPattern
      • Methods inherited from class java.text.Format

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

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

      • TimeFormat

        public TimeFormat​(int flags,
                          java.lang.String prefix,
                          java.lang.String suffix,
                          int numDecimals,
                          java.util.Locale locale)
        Constructs a new TimeFormat with automatically created pattern.
        Parameters:
        flags - 0 at the moment
        prefix - a string to prepend to the formatted string, or null
        suffix - a string to append to the formatted string, or null
        numDecimals - number of decimals, e.g. 3 for millisecs, 0 for secs
        locale - Locale to choose for number formatting
    • Method Detail

      • formatTime

        public java.lang.String formatTime​(java.lang.Number seconds)
        Creates a formatted string using a parameter for seconds synchronization: when called concurrently, explicit synchronization must be enforced
        Parameters:
        seconds - the time in seconds which will be formatted using an MM:SS.millis pattern
        Returns:
        the formatted string ready for display
      • parseTime

        public java.lang.Number parseTime​(java.lang.String str)
                                   throws java.text.ParseException
        Tries to parse a formatted time string (as produced by formatTime).
        Parameters:
        str - a formatted string such as "12:33.456"
        Returns:
        the number found by parsing the string. Either a Long, if the seconds are integer, otherwise a Double containing decimals for milliseconds.
        Throws:
        java.text.ParseException - if the string cannot be parsed