Am i missing something or is there a complete lack of support for String parsing of times without actual dates.
I have tried Date formatter, Calendar, GraegorianCalendar objects and to no avail.
The problem is such:
System that periodically appends a short text message to a file, as part of the message there are various timestamps for the information. The time stamps are UTC timezone the actual date of the messages is found in the filename so filename-01122010. However we can assume that the program will only be reading todays file.
Now I need to sort these time stamps and show them in order from the current time until some other predifined time.
00:01:20 Current time, taken from system
02:00:00 Final user defined time.
Assume a 24hour clock and UTC timezone for above example
Get Current Time;
Pass as ints to Calendar.set() methods
Convert to longs from epoch through getTime() calls
then order according to long values.
I find it hard to believe that i have to write my own parser in order to convert the time to a usable date. Have i missed a package, or is there an open source package for time parsing. I have tried the following but the parse method gets the date wrong as well as the time.
Any opinions, comments and better approaches to problem welcome.Code:
private static final DateFormat timestampFormatter = new SimpleDateFormat("HH:mm:ss");