1

I am doing mobile app which should be used world wide to set universal timing. for example I am in us then that app will take US timings and if the app is used in japan automatically that timing setting changes. that logic I want to write in db or script.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

What you want is a UTC/UT/GMT time. If you don't care that users might change the handset time, then you can use System.currentTimeMillis() Which is milliseconds since January 1st, 1970 in UTC. Then you can just convert that to a date as shown here.

When you later create a date using the UTC time, it will automatically be converted to the current time zone of the system/device. Like so.

If you don't trust users (and why would you?) you might want to hit a time server and get the current UTC time.

Community
  • 1
  • 1
DataDino
  • 1,507
  • 1
  • 15
  • 30