user3280180
user3280180

Reputation: 1403

JodaTime: Get DateTimeZone with offset xyz compared to utc

I want to use org.joda.time.DateTime. It need the following params:

DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, DateTimeZone zone)

Now the problem is, that I need the DateTimeZone, but I only know the offset compared to UTC, but how can I build this DateTime without knowing the exact name? All I have is a long value (e.g. 50400000) with offset in millis. The other values like year, hour, seconds etc are given.

Does anyone have some ideas?

Upvotes: 1

Views: 111

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1503389

If you know the offset, you can use DateTimeZone.forOffsetMillis to create a fixed-offset time zone.

That won't necessarily be the real time zone, but the offset alone isn't enough information to tell you the real time zone.

Upvotes: 1

Related Questions