#6 gprmc servlet time zone

Mihai Csaky

Hi Martin,
In the file src/org/opengts/war/gprmc/Data.java, we have a function: private long _parseFixtime(String dateStr, String timeStr){
/* unix 'Epoch' time? */
if (DateFormat == DATE_FORMAT_EPOCH) {
String epochStr = !dateStr.equals("")? dateStr : timeStr;
long timestamp = StringTools.parseLong(epochStr, 0L);
if (timestamp > MaxTimestamp) { // (long)Integer.MAX_VALUE * 2)
timestamp /= 1000L; // timestamp was specified in milliseconds
return (timestamp > 0L)? timestamp : DateTime.getCurrentTimeSec();

I think this should take in account also the current time zone, because I get always the data inserted with GMT, when is valid. Or is there another way to have correct time-date values for other time-zones?

What happens: I am sending from my device locations based on wireless network, which don't have timestamps, so the gprmc servlet is inserting the server timestamp and all looks ok, they have the correct time and date.

Now, I am going out, the GPS is active and I get GPS locations with timestamp. This timestamp is now inserted "as it is", at GMT, making the new location much older (I am at GMT+2), that the previous location.

GPRMC servlet is configured to use "EPOCH" date format.



  • Martin Flynn

    Martin Flynn - 2010-08-04
    • priority: 5 --> 1
  • Martin Flynn

    Martin Flynn - 2010-08-04

    An "Epoch" timestamp is based on GMT ("Epoch" time is the number of seconds since midnight January 1, 1970). The timestamp stored in the EventData table should always be in Epoch GMT format. When displayed on a report, the time can then be converted to the preferred timezone for the user selecting the report or map. When the above code uses "DateTime.getCurrentTimeSec()", it assumes that the current system clock is set correctly. The "getCurrentTimeSec()" always returns the proper Epoch/Unix time regardless of the default timezone set for the current system time (this method does however require that the clock does specify an accurate time).

    Based on your description, it may be that your system clock is not set properly, so the 'getCurrentTimeSec()' may not be able to calculate the proper Epoch/Unix time.
    Then when data arrives from GPS receiver, which allows a properly calculated Epoch/Unix time, the GPS time appears differently than the current system time.

    - Martin

  • Mihai Csaky

    Mihai Csaky - 2010-08-04

    Yes, thank you Martin, how stupid of me :) The system was configured to use localtime, so the timezone was ignored and 'getCurrentTimeSec()' always returned GMT+2.

  • Martin Flynn

    Martin Flynn - 2010-08-05
    • status: open --> closed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks