Skip to content

Commit

Permalink
fix(core): timezone offset issues in utils
Browse files Browse the repository at this point in the history
A bit more timezone correction in seconds vs milliseconds conversion
  • Loading branch information
AidanHost authored Aug 6, 2020
1 parent 8b0e189 commit cb6a1d4
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public static WritableMap getExceptionMap(Exception exception) {

public static String timestampToUTC(long timestamp) {
Calendar calendar = Calendar.getInstance();
Date date = new Date(timestamp + calendar.getTimeZone().getOffset(timestamp));
long millisTimestamp = timestamp * 1000;
Date date = new Date(millisTimestamp + calendar.getTimeZone().getOffset(millisTimestamp));
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
format.setTimeZone(TimeZone.getTimeZone("UTC"));
return format.format(date);
Expand Down

0 comments on commit cb6a1d4

Please sign in to comment.