I have to check if difference between time on server and Android device system time more then 1 hour. For now I have this string from server:
2020-08-24T11:50:18.613+0300
these is constant I use for SimpleDateFormat:
private static final String SYSTEM_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
problem is when I try to convert string date to Date class I am getting this:
Mon Aug 24 13:50:18 GMT+05:00 2020
As I understand +05:00 there is because it is time zone which set at Android device as default. That is how I get this Date:
Locale locale = new Locale("ru","RU");
DateFormat df = new SimpleDateFormat(SYSTEM_FORMAT, locale);
df.setTimeZone(TimeZone.getTimeZone("Europe/Moscow"));
Date date = df.parse(serverDate);
As you can see even setting time zone to +3 (Moscow time) does not make Date which I expect. I know I can compare it using just string, but demands are to compare Dates