Cannot use Joda for Android UnitTests
Closed this issue · 1 comments
I am trying to write UnitTests that deal a lot with DateTime and wanted to make them work in all time zones. Therefore I wanted to create DateTime objects which represent a relative timestamp from a given UTC timestamp.
However all my times are missing a date and have a funny time.
My UTC timestamp is:
private static final long SESSION_START_UTC = 1547222580L; //Fri, 11 Jan 2019 16:03:00 UTC
My Joda DateTimes all look like:
get24hStringLocalTime.dateTimeUtc = 1970-01-18T21:47:02.580Z
get24hStringLocalTime.dateTimeDefault = 1970-01-18T22:46:02.580+01:00
So the conversion from UTC to local time works, but the time itself is wrong and also the date is wrong.
I assume this has something to do with a missing JodaTimeAndroid.init(this);
- but how can I do this in a UnitTest?
I did a mistake myself and forgot to multiply the timestampUtc by 1000 (because it is in seconds)