This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Parsing Date/Time String - Urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Parsing Date/Time String - Urgent" Watch "Parsing Date/Time String - Urgent" New topic
Author

Parsing Date/Time String - Urgent

Zafer Abu saeed
Ranch Hand

Joined: Mar 28, 2004
Posts: 40
Hello all,

I have a problem parsing a String which represents a time (time only).
I'm using a DateFormat class with the default Locale and TimeZone,

When I use DateFormat.getTimeInstance(DateFormat.MEDIUM), the String will be parsed correctly.
But when I use DateFormat.getTimeInstance(DateFormat.FULL) the resulting Date object will represent a time that is one-hour-before the time represented by the String.

example:


Will print:
Thu Jan 01 15:00:00 EET 1970
Thu Jan 01 14:00:00 EET 1970

Can any body help please?


Thanks,<br /> Zafer<br /> SCJP, SCWCD
Fletcher Estes
Ranch Hand

Joined: Jul 01, 2004
Posts: 108
I get a parse exception when I run your code, and a different result for the date that did parse:

What version of Java are you using? It looks like the original String you're attempting to parse is invalid.
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
I ran your codes and have the same issue as you. Was kind of puzzled, but as I read the API:


SHORT is completely numeric, such as 12.13.52 or 3:30pm
MEDIUM is longer, such as Jan 12, 1952
LONG is longer, such as January 12, 1952 or 3:30:32pm
FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST.


I think, the difference is caused by the style you used. If you use both LONG and FULL, you'd get the same output.

Hope this helps.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing Date/Time String - Urgent
 
Similar Threads
epoch is wrong
Date 01/01/1970 returning non-zero value for time
TimeZone Conversion
why this strange behaviour in DateFormat.parse()
Doubt in Data