From a9f2d0a1e1fc4d183c16c1f5b1b0e7d89361cd35 Mon Sep 17 00:00:00 2001 From: Himanshu Soni Date: Thu, 15 Jun 2017 10:33:21 +0530 Subject: [PATCH] GMT date fix as suggested by @ThomasDaheim --- .gitignore | 61 +++++++++++++++++++++++++++++++ src/com/hs/gpxparser/BaseGPX.java | 44 ++++++++++++---------- 2 files changed, 85 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index ba436db..e938520 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,64 @@ bin/ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +### Java template +# Compiled class file + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) + +# Package Files # +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml diff --git a/src/com/hs/gpxparser/BaseGPX.java b/src/com/hs/gpxparser/BaseGPX.java index 5636d7c..f9a4e7a 100644 --- a/src/com/hs/gpxparser/BaseGPX.java +++ b/src/com/hs/gpxparser/BaseGPX.java @@ -2,31 +2,35 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.TimeZone; import com.hs.gpxparser.extension.IExtensionParser; class BaseGPX { - protected final SimpleDateFormat xmlDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - protected final ArrayList extensionParsers = new ArrayList(); + final SimpleDateFormat xmlDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + final ArrayList extensionParsers = new ArrayList<>(); - /** - * Adds a new extension parser to be used when parsing a gpx steam - * - * @param parser - * an instance of a {@link IExtensionParser} implementation - */ - public void addExtensionParser(IExtensionParser parser) { - this.extensionParsers.add(parser); - } + BaseGPX() { + // TF, 20170515: iso6801 dates are always in GMT timezone + xmlDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + } - /** - * Removes an extension parser previously added - * - * @param parser - * an instance of a {@link IExtensionParser} implementation - */ - public void removeExtensionParser(IExtensionParser parser) { - this.extensionParsers.remove(parser); - } + /** + * Adds a new extension parser to be used when parsing a gpx steam + * + * @param parser an instance of a {@link IExtensionParser} implementation + */ + public void addExtensionParser(IExtensionParser parser) { + this.extensionParsers.add(parser); + } + + /** + * Removes an extension parser previously added + * + * @param parser an instance of a {@link IExtensionParser} implementation + */ + public void removeExtensionParser(IExtensionParser parser) { + this.extensionParsers.remove(parser); + } }