I have a ISO 8601 date, lets say: 2012-01-19T19:00-05:00
My machine timezone is GMT+1
I\'m trying to use joda to parse this and convert
The Joda-Time team has told us to migrate to the java.time framework built into Java 8 and later. The java.time framework is defined by JSR 310. Much of the java.time functionality has been back-ported to Java 6 & 7 and further adapted for Android.
The java.time classes include OffsetDateTime to represent a moment on the timeline with an offset-from-UTC but not a full time zone.
The java.time classes use the standard ISO 8601 formats by default when parsing or generating strings. So no need to define a formatting pattern.
String input = "2012-01-19T19:00-05:00";
OffsetDateTime odt = OffsetDateTime.parse( input );
A time zone is an offset plus rules for handling anomalies such as Daylight Saving Time (DST). A proper time zone name uses a continent/region
format. You can assign a time zone (ZoneId) to an OffsetDateTime
to get a ZonedDateTime.
ZoneId zoneId = ZoneId.of( "America/Montreal" );
ZonedDateTime zdt = odt.atZoneSameInstant( zoneId );