Repository navigation
GPX: fix timestamp representation - #379
Conversation
|
Thanks, this would be really a nice cleanup :) ! Did you try some of the common GPX programs if they are okay with this? (basecamp, some online tools, josm, osm.org?) |
|
Most readers (online, apps) are versatile enough to parse more than one timestamp patterns. But going the other way, wherever I checked for official produced gpx files, I saw them following the spec. |
|
When we use 'Z' shouldn't we force +0? I.e.: SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(formatter.format(new Date()));Otherwise I'll get incorrect time when using default time zone here in Germany. |
|
What do you mean, don't you get with the above code the UTC time ? |
|
It will correctly use the local or specified time zone but ignores the offset as we always write 'Z'. I think you can easily try on your own. It should give you different times (except you are in london :)) but it will give you identical times |
|
Right now it gave me |
|
That's the correct UTC time, what do you get? |
|
Strange, that you get it correctly. I get Just to be sure, did you try this: SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
formatter.setTimeZone(TimeZone.getDefault());
System.out.println(formatter.format(new Date())); |
|
The UTC timezone is needed or else as you said we'll get our current time. I don't remember Java to have changes in that part (I'm in Linux with 7). |
|
Okay, but then this old code is wrong with your change: TimeZone tz = TimeZone.getDefault();
if (!Helper.isEmpty(timeZoneId))
tz = TimeZone.getTimeZone(timeZoneId);
formatter.setTimeZone(tz);and we should always use UTC and remove the timeZone parameter, right? |
|
Yes you are correct, to be with the spec we shouldn't provide the user any timezone option, but use internally only UTC. |
|
Peter I pushed a new commit removing the timezone parameter and making the UTC default. Also I think that in case of not provided |
|
Thanks & yes, you are right regarding the startTimeMillis |
|
I pushed another commit regarding |
GPX export: avoid hack for timestamp representation, use current time instead of 0 if no start time provided
|
Thanks! |
* added translations * added german translation for towerslope * update german translations * replaced questions marks with numbers and added custom icon option * reformat code * added batch numbers to prevent duplicate icons * removed icon option in config; improved visabillity of batchNumbers * moved icons to seperate files; optimization * bug fix * separate empty key from default profile name * a little less code * improved key selection while creating customProfiles Record * separate empty key from default profile name (graphhopper#1) * separate empty key from default profile name * a little less code --------- Co-authored-by: Peter <[email protected]>
Peter I think that in GPX the timestamps should be in UTC with ISO 8601 representation and end with the 'Z' suffix.
http://www.topografix.com/gpx_manual.asp#time
And to conform with spec, probably it's not necessary to provide the timezone as parameter to the createGPX method.