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

前端 未结 5 1741
孤街浪徒
孤街浪徒 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:36

    If you're working in Java prior to Java 8, you should probably use Joda Time for your conversions. Take a look at this question: Date and time conversion to some other Timezone in java

    If you're working in Java 8 and newer (or if you plan to start the upgrade process in your company), Java 8 includes a proper Date/Time library and the creators of Joda recommend switching to using that. Take a look at this question: Joda Time - Convert UTC DateTime to Date - Using a Version 1.2.1.1 of Joda

提交回复
热议问题