I am trying to convert server date string to my local/device set local time but without success. I am using Joda time library.
What i am trying to do:
private static String FORMAT_DATE_SERVER = "YYYY-MM-dd'T'HH:mm:ssZ";
public static DateTime parseServerDateToLocal(String raw_date) {
DateTime result = DateTime.parse(raw_date, DateTimeFormat.forPattern(FORMAT_DATE_SERVER)).withZone(DateTimeZone.getDefault());
return result;
}
Still returns the DateTime from the server. I cant manage to make it to return the proper hour/datetime.
I read many post about this, but i didnt manage to make it simple, clean and working.
The solution i have found:
in your application class, or somewhere else, initialise JodaTimeAndroid:
after this initialisation the date will be automatically converted to your zone, with proper offset. This is how you parse the data then:
In my case, with offset (+2h), the returned data is: