I want to use Joda Time to parse a time that does not have an explicit time zone with a specific default zone (e.g. UTC), but use an explicit zone if one is present. For instance:
parse("2014-02-11T12:00:00")
parse("2014-02-11T12:00:00+02:00")
Everything I tried has some problems:
DateTime.parse("2014-02-11T12:00:00")
ISODateTimeFormat.dateTimeParser()
.withZone(DateTimeZone.UTC)
.parseDateTime("2014-02-11T12:00:00+02:00");
Basically, I want the behavior withZone()and withOffsetParsed()at the same time, but they override each other.
I do not want to change the default time zone for the entire JVM.
source
share