Package de.sciss.gui
Class TimeFormat
- java.lang.Object
-
- java.text.Format
-
- java.text.MessageFormat
-
- de.sciss.gui.TimeFormat
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class TimeFormat extends java.text.MessageFormatAMessageFormatsubclass for displaying time values in minutes and seconds.- See Also:
NumberField.HHMMSS, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TimeFormat(int flags, java.lang.String prefix, java.lang.String suffix, int numDecimals, java.util.Locale locale)Constructs a newTimeFormatwith automatically created pattern.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringformatTime(java.lang.Number seconds)Creates a formatted string using a parameter for seconds synchronization: when called concurrently, explicit synchronization must be enforcedjava.lang.NumberparseTime(java.lang.String str)Tries to parse a formatted time string (as produced byformatTime).-
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
-
-
-
-
Constructor Detail
-
TimeFormat
public TimeFormat(int flags, java.lang.String prefix, java.lang.String suffix, int numDecimals, java.util.Locale locale)Constructs a newTimeFormatwith automatically created pattern.- Parameters:
flags- 0 at the momentprefix- a string to prepend to the formatted string, ornullsuffix- a string to append to the formatted string, ornullnumDecimals- number of decimals, e.g. 3 for millisecs, 0 for secslocale-Localeto 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.ParseExceptionTries to parse a formatted time string (as produced byformatTime).- 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
-
-