How to handle time zone difference between server and native android application?

前端 未结 5 1657
孤街浪徒
孤街浪徒 2021-02-19 20:52

Suppose that my server located in USA and I live in Russia. We know that they have different time zones.

My application getting text(String) from server. An

5条回答
  •  爱一瞬间的悲伤
    2021-02-19 21:34

    The Calendar class can convert times between timezones, so long as you know what timezone the server and the client use. To avoid problems in the future if you ever move the server, its best to define what the time in the database should be. I prefer to use UTC for this as its standard, but you can use any timezone you wish, so long as its defined and in your documentation so you'll know in the future.

    Here's a question that shows how to do it: Date and time conversion to some other Timezone in java

提交回复
热议问题