mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-01-12 22:50:20 +08:00
fix(core): timezone offset issues in utils
A bit more timezone correction in seconds vs milliseconds conversion
This commit is contained in:
@@ -98,7 +98,8 @@ public class SharedUtils {
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user