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
There isn't really such as thing as "Russia time zone" or "USA time zone". Both of those countries have several different time zones. See the Wikipedia articles on Time in Russia and Time in the USA.
You should always write server code such that it is not dependent on the time zone that the server is running in. Usually this is done by storing all time as UTC. Since the client is an Android device, just convert to and from local time on the client, sending just UTC to/from the server.
If you're working in Java, you should probably use Joda Time for your conversions. It is much cleaner and easier to use than the Calendar
class.
Update
As Basil pointed out in comments, the Joda-Time project is now in maintenance mode. The team advises migration to the java.time
classes defined by JSR 310. For earlier Android, see the ThreeTen-Backport and ThreeTenABP projects. See How to use….