[Data] Fix setting correct time zone in ISO date parsing.

This commit is contained in:
Kuba Szczodrzyński 2020-05-18 12:22:21 +02:00
parent f13995aa5c
commit 5dcb3fd580

View File

@ -112,7 +112,9 @@ public class Date implements Comparable<Date> {
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
c.set(Integer.parseInt(dateTime.substring(0, 4)), Integer.parseInt(dateTime.substring(5, 7)) - 1, Integer.parseInt(dateTime.substring(8, 10)), Integer.parseInt(dateTime.substring(11, 13)), Integer.parseInt(dateTime.substring(14, 16)), Integer.parseInt(dateTime.substring(17, 19))); c.set(Integer.parseInt(dateTime.substring(0, 4)), Integer.parseInt(dateTime.substring(5, 7)) - 1, Integer.parseInt(dateTime.substring(8, 10)), Integer.parseInt(dateTime.substring(11, 13)), Integer.parseInt(dateTime.substring(14, 16)), Integer.parseInt(dateTime.substring(17, 19)));
c.set(Calendar.MILLISECOND, 0); c.set(Calendar.MILLISECOND, 0);
if (dateTime.endsWith("Z")) {
c.setTimeZone(TimeZone.getTimeZone("UTC")); c.setTimeZone(TimeZone.getTimeZone("UTC"));
}
return c.getTimeInMillis(); return c.getTimeInMillis();
} }
catch (Exception e) { catch (Exception e) {