From a3f11bcc3f1b70a01ea3b679032d7f64cac6b3f4 Mon Sep 17 00:00:00 2001 From: bvn13 Date: Wed, 1 Mar 2023 23:18:37 +0300 Subject: [PATCH 1/3] Update for next development version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16ffdc8..d08a310 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ GpxAndroidSdk me.bvn13.sdk.android.gpx - 1.9 + 1.10-SNAPSHOT jar From 3845cdcaa6383b09fdc706b562f17c734e5401e4 Mon Sep 17 00:00:00 2001 From: bvn13 Date: Thu, 2 Mar 2023 17:42:08 +0300 Subject: [PATCH 2/3] catching errors while writing date --- .gitignore | 7 ++++++- pom.xml | 9 +++++++-- .../me/bvn13/sdk/android/gpx/GpxWriter.kt | 19 +++++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 8a67d03..8350a7f 100644 --- a/.gitignore +++ b/.gitignore @@ -368,4 +368,9 @@ gradle-app.setting **/build/ # End of https://www.toptal.com/developers/gitignore/api/java,gradle,git,intellij,linux,windows,macos,node -**/target/ \ No newline at end of file +**/target/ + +.idea/ +.idea/** + +GpxAndroidSdk.iml \ No newline at end of file diff --git a/pom.xml b/pom.xml index d08a310..dc0551c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ GpxAndroidSdk me.bvn13.sdk.android.gpx - 1.10-SNAPSHOT + 1.10.1-SNAPSHOT jar @@ -58,6 +58,11 @@ + + org.slf4j + slf4j-api + 2.0.6 + org.jetbrains.kotlin kotlin-test-junit5 @@ -234,7 +239,7 @@ develop true - 2 + 3 diff --git a/src/main/kotlin/me/bvn13/sdk/android/gpx/GpxWriter.kt b/src/main/kotlin/me/bvn13/sdk/android/gpx/GpxWriter.kt index a4005e9..1dc9085 100644 --- a/src/main/kotlin/me/bvn13/sdk/android/gpx/GpxWriter.kt +++ b/src/main/kotlin/me/bvn13/sdk/android/gpx/GpxWriter.kt @@ -82,6 +82,9 @@ import me.bvn13.sdk.android.gpx.GpxConstant.Companion.HEADER import me.bvn13.sdk.android.gpx.GpxWriter.Companion.SCHEMA_LOCATION import me.bvn13.sdk.android.gpx.GpxWriter.Companion.XMLNS import me.bvn13.sdk.android.gpx.GpxWriter.Companion.XMLNS_XSI +import me.bvn13.sdk.android.gpx.GpxWriter.Companion.log +import org.slf4j.Logger +import org.slf4j.LoggerFactory import java.time.Clock import java.time.OffsetDateTime @@ -257,10 +260,17 @@ fun toXmlString(value: Double?, nodeName: String) = if (value != null) { "" } -fun toXmlString(value: OffsetDateTime?, nodeName: String) = if (value != null) { - "<${nodeName}>${value.format(DTF)}" -} else { - "" +fun toXmlString(value: OffsetDateTime?, nodeName: String): String { + if (value != null) { + try { + return "<${nodeName}>${value.format(DTF)}" + } catch (e: Exception) { + log.warn(String.format("Unable to format datetime value %s in node %s", value, nodeName), e) + return "" + } + } else { + return "" + } } fun toXmlString(value: Map?) = value?.entries?.joinToString(separator = "") { @@ -280,5 +290,6 @@ class GpxWriter { const val XMLNS = "http://www.topografix.com/GPX/1/1" const val XMLNS_XSI = "http://www.w3.org/2001/XMLSchema-instance" const val SCHEMA_LOCATION = "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" + val log: Logger = LoggerFactory.getLogger(GpxWriter.javaClass) } } From 4425533d55bcd71482997e36507eb5f03d08ea11 Mon Sep 17 00:00:00 2001 From: bvn13 Date: Thu, 2 Mar 2023 17:42:39 +0300 Subject: [PATCH 3/3] Update versions for release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dc0551c..6ca3e56 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ GpxAndroidSdk me.bvn13.sdk.android.gpx - 1.10.1-SNAPSHOT + 1.10.1 jar