Take the 2-minute tour ×

I managed to convert a valid date string in a different timezone to UTC as follows.

String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
DateTimeFormatter DATETIME_FORMATTER = DateTimeFormat.forPattern(DATE_FORMAT);
DateTimeZone dateTimeZone = DateTimeZone.forID("-03:00");
//date is 2000-01-01 00:00:00 -03:00
DateTime date =    DATETIME_FORMATTER.withZone(dateTimeZone).parseDateTime("2000-01-01 00:00:00"));
System.out.println("Current date is: " + date.toString());
//now convert to UTC
DateTime convertedDate = date.toDateTime(DateTimeZone.UTC);
System.out.println("Converted date: " + date.toString());

The result is

Current date is: 2000-01-01T00:00:00.000-03:00
Converted date: 2000-01-01T03:00:00.000Z

Is there a shorter/better way of doing this? I want the final date to be a Joda-Time DateTime object.

share|improve this question

2 Answers 2

You can convert the time zone of any DateTime using withZone(). If the input string doesn't specify the time-zone offset then you have to add it as you are doing, so your code is fairly optimal.

share|improve this answer

One improvement over your example code might be replacing the hard-coded "-3:00" offset with a time zone name. That would allow Joda-Time to make adjustments for any possible Daylight Saving Time (DST). See doc for DateTimeZone.forID().


DateTimeZone dateTimeZone = DateTimeZone.forID("America/Sao_Paulo");

instead of this:


Time Zone list (possibly outdated, read note):

share|improve this answer

Your Answer


