File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Can't parse dates with full zone name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can Watch "Can New topic

Can't parse dates with full zone name

Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
I am trying to parse a date with full zone names like 'Canada/Newfoundland' as shown below-
But it leads to exception-
Any ideas?

My Blog
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Well I just gone through the Docs of SimpleDateFormat class.

Format Pattern
"yyyy.MM.dd G 'at' hh:mm:ss z" ->> 1996.07.10 AD at 15:08:56 PDT
"EEE, MMM d, ''yy" ->> Wed, July 10, '96
"h:mm a" ->> 12:08 PM
"hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time
"K:mm a, z" ->> 0:00 PM, PST
"yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 1996.July.10 AD 12:08 PM

I was not able to find the format you are giving it. I think it should be modified.


My Blog SCJP 5 SCWCD 5
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46349
Go through the TimeZone and DateFormat classes and you can get a TimeZone object from Canada/Newfoundland, then pass it to your DateFormat object. That might sort out your problem.
I agree. Here's the link:
subject: Can't parse dates with full zone name
It's not a secret anymore!