androiddatetimeandroid-jodatime

JodaTime confused about TimeZone offset


I receive a Date String like "2018-06-21T13:30:00Z" I parse it with the pattern "yyyy-MM-dd'T'HH:mm:ssZ"

I am in GMT+2 and the result looks like 2018-06-21T15:30:00.000+02:00 while i expected it to look like this 2018-06-21T13:30:00.000+02:00

Is the offset supposed to be already applied in the HH:mm:ss part of the Result?

Code

DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ").parseDateTime("2018-06-21T13:30:00Z")

joda:2.9.7


Solution

  • Yes the date time given is in the local time of +02:00.

    From ISO 8601 Wikipedia Time offsets from UTC:

    The following times all refer to the same moment: "18:30Z", "22:30+04", "1130−0700", and "15:00−03:30". Nautical time zone letters are not used with the exception of Z. To calculate UTC time one has to subtract the offset from the local time, e.g. for "15:00−03:30" do 15:00 − (−03:30) to get 18:30 UTC.

    So for your case: 2018-06-21T15:30:00.000+02:00 means 15:30 - 02:00 so a UTC of 13:30