I want to parse a DateTime using the joda library (in scala, but should be the same with java).
The source looks like
val dateParser = DateTimeFormat
The issue is because CEST
is a short zone name that is not unique. See the detailed discussion from DateTimeFormatter Bug parsing with general time zones in US Locale?
You can use the latest version from github that should contain a fix, see this commit.
You should be able to use DateTimeFormatterBuilder#appendTimeZoneShortName
to add CEST
as an alias for "America/Chicago" or to how you would like to interpret CEST
.
Apply parsing with a java.util.Date
instance allows you to apply a workaround since CEST
is not well parsing since not unique:
DateFormat dateParser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
DateTime dateTime = new DateTime(dateParser.parse("2012-08-28 15:35:00 CEST"));
//Here parsed `java.util.Date` instance is back to an instance of org.jodatime.DateTime`
Benefit of this workaround: to not bother with "which version works with this timezone???"