Java – In joda time how to convert time zone without changing time

datetimejavajodatime

I am getting UTC timestamp from database which is I am setting into a JodaTime DateTime instance

DateTime dt = new DateTime(timestamp.getTime());

It stores the time perfectly say 10:00 AM but with local time zone. E.g, I am in IST time zone which is +5:30 from UTC

I have tried lots of things for changing the timezone but with every thing it changes the time from 10:00 AM to something else by using +5:30 difference

Is there any way by which I can change TimeZone without affecting current time

EDIT:
If my current time is:

2013-09-25 11:27:34 AM      UTC

Following is the result when I use this new DateTime(timestamp.getTime());

2013-09-25 11:27:34 AM  Asia/Kolkata

And following is the result when I use this new DateTime(timestamp.getTime(), DateTimeZone.UTC);

2013-09-25 05:57:34 AM  UTC

Best Answer

You can use class LocalDateTime

LocalDateTime dt = new LocalDateTime(t.getTime()); 

and convert LocalDateTime to DateTime

DateTime dt = new LocalDateTime(timestamp.getTime()).toDateTime(DateTimeZone.UTC);  

Joda DateTime treats any time in millis like "millis since 1970y in current time zone". So, when you create DateTime instance, it is created with current time zone.