0

I'm parsing a xs:datetime to joda DateTime, but would like to parse it without the timezone, and let the date+time remain unchanged.

How could I achieve this? The following subtracts the timezone instead, but that's not what I want.

ISODateTimeFormat.dateTimeParser().parseDateTime("2015-10-25T08:45:00.000+11:00"); //2015-10-24 23:45:00 WHY?
2
  • What do you mean 'subtracts the timezone'? That code looks correct for handling date-times. I notice that the time in the comment is 10 hours before the parsed time, not 11 - however it looks like October 25 is when DST changes, which would explain that.
    – Adam S
    Feb 9, 2015 at 17:11
  • @AdamS If I only consider the input string then it is NOT correct to apply any DST-changes because an offset like +11:00 is just a fixed offset without any DST-Information. Feb 9, 2015 at 18:43

1 Answer 1

1

Use the right temporal type:

LocalDateTime ldt =
    ISODateTimeFormat.dateTimeParser().parseLocalDateTime("2015-10-25T08:45:00.000+11:00");
System.out.println(ldt); // 2015-10-25T08:45:00.000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.