Reputation: 1469
Say I get a timestamp mTimestamp
for New york. Say further that my local timezone is California. If the new york time zone would translate to say 9:03:45PM for new york, how do I get the equivalent timestamp for 9:03:45PM in california? I hope the question makes sense, this is the best I can articulate it.
So the function would convert a timestamp that would be say 9pm in New York to a timestamp that would be 9pm in California.
Upvotes: 0
Views: 124
Reputation: 44061
Since you have tagged your question with "datetime" and "jodatime" I assume that you speak about the class org.joda.time.DateTime
.
This class has indeed an inner time zone state! And if you just look at the methods withZone()
or withZoneRetainFields() then you can change this state to another time zone. In your case you want the same local time but change the time zone and hence change the physical instant on global time line.
DateTime newYork =
new DateTime(2014, 1, 17, 21, 3, 45, DateTimeZone.forID("America/New_York");
DateTime california =
newYork.withZoneRetainFields(DateTimeZone.forID("America/Los_Angeles"));
Upvotes: 1
Reputation: 60
I think the time stamp will be same because the time is still same but if you want to convert time in two different locales and then convert time from one locale to time at a different locale at the same time that would actually make more sense
Upvotes: 0