instacart / truetime-android

Android NTP time library. Get the true current time impervious to device clock time changes
https://tech.instacart.com/truetime/
Apache License 2.0
1.41k stars 194 forks source link

How to get time with different timezone #115

Open ZakariaJawas opened 5 years ago

ZakariaJawas commented 5 years ago

Is it possible to force TrueTime to get time in a different timezone the phone is configured with

SuvabBaral commented 7 months ago

I too am looking for this. Basically was looking for a way to supply a timezone to the TrueTime library so that even if the device time/timezone is changed, we can still get the correct time in the desired timezone.

@kaushikgopal , any thoughts on it?

harshmauryaa commented 3 days ago

Its too late, but if you are using Java 8 and above you can follow this link - https://mkyong.com/java/java-convert-date-and-time-between-timezone

Note The java.util.Date has no concept of time zone, and only represents the number of seconds passed since the Unix epoch time – 1970-01-01T00:00:00Z. But, if you print the Date object directly, the Date object will be always printed with the default system time zone.