Package com.twelvemonkeys.util
Class TimeFormat
- java.lang.Object
-
- java.text.Format
-
- com.twelvemonkeys.util.TimeFormat
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class TimeFormat extends java.text.FormatFormat for converting and parsing time.The format is expressed in a string as follows:
- m (or any multiple of m's)
- the minutes part (padded with 0's, if number has less digits than the number of m's) m -> 0,1,...,59,60,61,... mm -> 00,01,...,59,60,61,...
- s or ss
- the seconds part (padded with 0's, if number has less digits than the number of s's) s -> 0,1,...,59 ss -> 00,01,...,59
- S
- all seconds (including the ones above 59)
May not handle all cases, and formats... ;-) Safest is: Always delimiters between the minutes (m) and seconds (s) part.
Known bugs:
The last character in the formatString is not escaped, while it should be. The first character after an escaped character is escaped while is shouldn't be.
This is not a 100% compatible implementation of a java.text.Format.
- See Also:
Time, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static TimeFormatDEFAULT_FORMATThe default time format(package private) static java.lang.StringESCAPEprotected java.lang.StringformatStringprotected TimeFormatter[]formatterThe formatter array.(package private) static java.lang.StringMINUTE(package private) static java.lang.StringSECOND(package private) static java.lang.StringTIME
-
Constructor Summary
Constructors Constructor Description TimeFormat(java.lang.String pStr)Creates a new TimeFormat with the given formatString,
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringformat(Time pTime)Formats the the given time, using this format.java.lang.StringBufferformat(java.lang.Object pObj, java.lang.StringBuffer pToAppendTo, java.text.FieldPosition pPos)DUMMY IMPLEMENTATION!!java.lang.StringgetFormatString()Gets the format string.static TimeFormatgetInstance()DUMMY IMPLEMENTATION!! Not locale specific.(package private) static voidmain(java.lang.String[] argv)Main method for testing ONLYTimeparse(java.lang.String pStr)Parses a Time, according to this format.java.lang.ObjectparseObject(java.lang.String pStr, java.text.ParsePosition pStatus)DUMMY IMPLEMENTATION!!
-
-
-
Field Detail
-
MINUTE
static final java.lang.String MINUTE
- See Also:
- Constant Field Values
-
SECOND
static final java.lang.String SECOND
- See Also:
- Constant Field Values
-
TIME
static final java.lang.String TIME
- See Also:
- Constant Field Values
-
ESCAPE
static final java.lang.String ESCAPE
- See Also:
- Constant Field Values
-
DEFAULT_FORMAT
private static final TimeFormat DEFAULT_FORMAT
The default time format
-
formatString
protected java.lang.String formatString
-
formatter
protected TimeFormatter[] formatter
The formatter array.
-
-
Method Detail
-
main
static void main(java.lang.String[] argv)
Main method for testing ONLY
-
getInstance
public static TimeFormat getInstance()
DUMMY IMPLEMENTATION!! Not locale specific.
-
getFormatString
public java.lang.String getFormatString()
Gets the format string.
-
format
public java.lang.StringBuffer format(java.lang.Object pObj, java.lang.StringBuffer pToAppendTo, java.text.FieldPosition pPos)DUMMY IMPLEMENTATION!!- Specified by:
formatin classjava.text.Format
-
format
public java.lang.String format(Time pTime)
Formats the the given time, using this format.
-
parseObject
public java.lang.Object parseObject(java.lang.String pStr, java.text.ParsePosition pStatus)DUMMY IMPLEMENTATION!!- Specified by:
parseObjectin classjava.text.Format
-
parse
public Time parse(java.lang.String pStr)
Parses a Time, according to this format.Will bug on some formats. It's safest to always use delimiters between the minutes (m) and seconds (s) part.
-
-