You should just be able to use the ISODateTimeFormat
class that is built in to JodaTime. The example in the documentation is:
DateTime dt = new DateTime();
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
String str = fmt.print(dt);
Question
I want to convert my date "2013-03-04T23:00:00"
to "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
but I keep getting "2013-03-04'T'23:00:00.000+0000"
. Any help?
item.getEnd() is a XMLGregorianCalendar by the way.
Calendar calendar = item.getEnd().toGregorianCalendar();
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = calendar.getTime();
DateTime iso8601 = new DateTime(calendar);
iso8601.toString("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
Solution
You should just be able to use the ISODateTimeFormat
class that is built in to JodaTime. The example in the documentation is:
DateTime dt = new DateTime();
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
String str = fmt.print(dt);