File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Java 8 in Action
this week in the
Java in General
Can't parse dates with full zone name
Vinod K Singh
Joined: Sep 30, 2008
Jan 06, 2009 06:18:07
I am trying to parse a date with full zone names like 'Canada/Newfoundland' as shown below-
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzzz"); String str = "2003-02-17 09:00:00 Canada/Newfoundland"; // Date dt = sdf.parse(str);
But it leads to exception-
java.text.ParseException: Unparseable date: "2003-02-17 09:00:00 Canada/Newfoundland"
Joined: Aug 18, 2008
Jan 06, 2009 06:45:00
Well I just gone through the Docs of
"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,
"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.
SCJP 5 SCWCD 5
Joined: Oct 13, 2005
Jan 06, 2009 09:44:33
Go through the
classes and you can get a
object from Canada/Newfoundland, then pass it to your
object. That might sort out your problem.
rocket mass heater
subject: Can't parse dates with full zone name
SimpleDateFormat year problem
Time zone problem in date format
current time problem on AIX
Calendar() / Date() bug ???
date format conversion to MM/dd/yyyy hh:mm a
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014