I’m having trouble with my app trying to parse a date with the America/Chicago timezone. I have reviewed a bunch of other ParseException questions, and I think I’ve gotten all the common gotchas with date parsing in Java. The following code works for all other date/times I’ve encountered, but all the dates with the America/Chicago timezone are for some reason unparseable.
I set the locale for the dateFormat, and that didn’t matter. I checked that each of the other parts were fine, I removed invisible control characters, I re-typed the string to make sure no nefarious characters were copy/pasted in, yet it throws an exception every time.
Any thoughts?
dateFormat = new SimpleDateFormat("EEE MMM dd k:mm:ss zzz ");
dateString = "Wed May 02 15:45:47 America/Chicago ";
try {
entry.setDateTaken(dateFormat.parse(dateString));
} catch (java.text.ParseException e) { }
I have my reasons for wanting to not go the Joda route, and this is a simple enough thing I shouldn’t have to.
I believe the problem is that you’re using Olson time zone IDs, and I don’t think
SimpleDateFormatsupports parsing those. Certainly using your code I have the same problem with “Europe/London” so it’s not specific to Chicago. Can you give any examples with that style of time zone identifier which do work?