views:

1088

answers:

2

We are developing a j2me app for syncing contacts to/from a server. we are storing the update and create time (long mill sec) with each contact for conflict resolution/sync calculations.

Now as the client and server app can be in different time zones , how one can store time with time zone in a standard format (to take care diff time zones and daylight savings) for calculations at client and server side.

+3  A: 

I suggest you store all times in GMT+0 and convert the time only when you display it.

Peter Lawrey
+3  A: 

If you use System.currentTimeMillis() you don't have to worry about time zones, because it is in universal time. From System.currentTimeMillis() Javadoc:

public static long currentTimeMillis()

[...]

Returns: the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

The time zone UTC is Coordinated Universal Time, which is mostly GMT .

starblue
so on client and server if we store the time using System.currentTimeMillis() UTC , we don have to take care of time zones and daylight savings in our calculation for eg. long time1 ; long time2 ; if(time1-time2 >0) time1 occurred after time2 ???
Yes, time zones (including daylight savings time) are only taken into account for presenting dates to the user.
starblue