[JAVA: okhttp-gson, rest-assured, retrofit2] Don't generate Jackson import when serialization library is GSON (#18811)

* Partially revert "replace deprecated ISO8601Utils with StdDateFormat (#17052)"

This partially reverts commit 76560e34c9, namely anything
related to generators and samples using GSON instead of Jackson.

Changes to Jackson-only generation and generator-online regarding RFC3339DateFormat
are not being reverted.

* Test for default serialization library fallback

* Convert repetitive tests to parameterized test

* Add regression test for #18515

* [FEIGN] Only include <jackson-databind-version> property in pom.xml when required

* [RETROFIT2] Only include jackson-databind in gradle file when actually required

* [FEIGN] Don't include jackson dep's in sbt file when GSON is selected

* [FEIGN] Don't include jackson dep's in gradle file when GSON is selected

* DRY refactor JavaClientCodegen test code, increase readability

- use fluent assertions
- use helper method newTempFolder()
- use Java 9 static factory methods for maps
- don't declare variables that are only used once
- group declarations and usages
- use non-blocking java.nio.file API wherever possible

* Regenerate samples
This commit is contained in:
Philzen
2024-06-02 15:42:55 +02:00
committed by GitHub
parent 051abb82dc
commit ed2aad6756
44 changed files with 1340 additions and 2383 deletions

View File

@@ -123,8 +123,8 @@ dependencies {
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
implementation "com.brsanthu:migbase64:2.2"
implementation "com.github.scribejava:scribejava-core:$scribejava_version"
implementation "com.brsanthu:migbase64:2.2"

View File

@@ -319,8 +319,8 @@
<feign-version>13.2.1</feign-version>
<feign-form-version>3.8.0</feign-form-version>
<jackson-version>2.17.1</jackson-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<jackson-databind-version>2.17.1</jackson-databind-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<junit-version>5.10.0</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -31,16 +31,14 @@ import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
/*
* A JSON utility class
@@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -378,7 +371,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -388,7 +381,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -413,7 +406,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -432,7 +425,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -31,16 +31,14 @@ import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
/*
* A JSON utility class
@@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -338,7 +331,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -348,7 +341,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -373,7 +366,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -392,7 +385,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -31,16 +31,14 @@ import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
/*
* A JSON utility class
@@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -413,7 +406,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -423,7 +416,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -448,7 +441,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -467,7 +460,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -31,16 +31,14 @@ import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
/*
* A JSON utility class
@@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -338,7 +331,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -348,7 +341,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -373,7 +366,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -392,7 +385,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -31,16 +31,14 @@ import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
/*
* A JSON utility class
@@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -340,7 +333,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -350,7 +343,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -375,7 +368,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -394,7 +387,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -31,16 +31,14 @@ import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
/*
* A JSON utility class
@@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -413,7 +406,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -423,7 +416,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -448,7 +441,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -467,7 +460,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -31,16 +31,14 @@ import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
/*
* A JSON utility class
@@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -338,7 +331,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -348,7 +341,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -373,7 +366,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -392,7 +385,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -31,16 +31,14 @@ import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
/*
* A JSON utility class
@@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -338,7 +331,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -348,7 +341,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -373,7 +366,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -392,7 +385,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -305,11 +305,6 @@
<artifactId>jackson-databind-nullable</artifactId>
<version>${jackson-databind-nullable-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind-version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
@@ -350,7 +345,6 @@
<gson-version>2.10.1</gson-version>
<commons-lang3-version>3.13.0</commons-lang3-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<jackson-databind-version>2.16.0</jackson-databind-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<junit-version>5.10.0</junit-version>
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -31,16 +31,14 @@ import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
/*
* A JSON utility class
@@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -562,7 +555,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -572,7 +565,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -597,7 +590,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -616,7 +609,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -227,11 +227,6 @@
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind-version}</version>
</dependency>
<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@@ -241,6 +236,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
@@ -281,8 +280,8 @@
<rest-assured.version>5.3.2</rest-assured.version>
<gson-version>2.10.1</gson-version>
<gson-fire-version>1.9.0</gson-fire-version>
<jackson-databind-version>2.17.1</jackson-databind-version>
<jackson-version>2.17.1</jackson-version>
<jackson-databind-version>2.17.1</jackson-databind-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<beanvalidation-version>3.0.2</beanvalidation-version>

View File

@@ -226,11 +226,6 @@
<artifactId>gson-fire</artifactId>
<version>${gson-fire-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
@@ -262,7 +257,6 @@
<rest-assured.version>5.3.2</rest-assured.version>
<gson-version>2.10.1</gson-version>
<gson-fire-version>1.9.0</gson-fire-version>
<jackson-databind-version>2.17.1</jackson-databind-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<beanvalidation-version>3.0.2</beanvalidation-version>
<okio-version>3.6.0</okio-version>

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -35,14 +35,11 @@ import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
public class JSON {
private Gson gson;
@@ -53,11 +50,6 @@ public class JSON {
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
@@ -380,7 +372,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -390,7 +382,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -415,7 +407,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -434,7 +426,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -99,8 +99,8 @@ if(hasProperty('target') && target == 'android') {
ext {
oltu_version = "1.0.1"
retrofit_version = "2.3.0"
jackson_databind_version = "2.17.1"
jackson_version = "2.17.1"
jackson_databind_version = "2.17.1"
javax_ws_rs_api_version = "2.1.1"
jackson_databind_nullable_version = "0.2.6"
play_version = "2.6.7"
@@ -125,10 +125,10 @@ dependencies {
implementation "com.squareup.retrofit2:converter-jackson:$retrofit_version"
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
implementation "javax.ws.rs:javax.ws.rs-api:$javax_ws_rs_api_version"
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
}

View File

@@ -204,11 +204,6 @@
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind-version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -252,6 +247,11 @@
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind-version}</version>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
@@ -277,6 +277,11 @@
<artifactId>play-ahc-ws_2.12</artifactId>
<version>${play-version}</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${beanvalidation-version}</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>

View File

@@ -99,7 +99,6 @@ if(hasProperty('target') && target == 'android') {
ext {
oltu_version = "1.0.1"
retrofit_version = "2.3.0"
jackson_databind_version = "2.17.1"
jakarta_annotation_version = "1.3.5"
swagger_annotations_version = "1.5.22"
junit_version = "4.13.2"
@@ -116,7 +115,6 @@ dependencies {
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
}
implementation "io.gsonfire:gson-fire:$json_fire_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
}

View File

@@ -204,11 +204,6 @@
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind-version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -267,7 +262,6 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<gson-fire-version>1.9.0</gson-fire-version>
<swagger-annotations-version>1.6.3</swagger-annotations-version>
<jackson-databind-version>2.17.1</jackson-databind-version>
<retrofit-version>2.5.0</retrofit-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<oltu-version>1.0.1</oltu-version>

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -34,14 +34,11 @@ import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
public class JSON {
private Gson gson;
@@ -50,11 +47,6 @@ public class JSON {
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
.registerTypeSelector(Animal.class, new TypeSelector() {
@@ -293,7 +285,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -303,7 +295,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -329,7 +321,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -348,7 +340,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -99,7 +99,6 @@ if(hasProperty('target') && target == 'android') {
ext {
oltu_version = "1.0.1"
retrofit_version = "2.3.0"
jackson_databind_version = "2.17.1"
jakarta_annotation_version = "1.3.5"
swagger_annotations_version = "1.5.22"
junit_version = "4.13.2"
@@ -119,7 +118,6 @@ dependencies {
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
}
implementation "io.gsonfire:gson-fire:$json_fire_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
}

View File

@@ -204,11 +204,6 @@
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind-version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -277,7 +272,6 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<gson-fire-version>1.9.0</gson-fire-version>
<swagger-annotations-version>1.6.3</swagger-annotations-version>
<jackson-databind-version>2.17.1</jackson-databind-version>
<retrofit-version>2.5.0</retrofit-version>
<rxjava-version>2.1.1</rxjava-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -34,14 +34,11 @@ import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
public class JSON {
private Gson gson;
@@ -50,11 +47,6 @@ public class JSON {
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
.registerTypeSelector(Animal.class, new TypeSelector() {
@@ -293,7 +285,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -303,7 +295,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -329,7 +321,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -348,7 +340,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}

View File

@@ -99,7 +99,6 @@ if(hasProperty('target') && target == 'android') {
ext {
oltu_version = "1.0.1"
retrofit_version = "2.3.0"
jackson_databind_version = "2.17.1"
jakarta_annotation_version = "1.3.5"
swagger_annotations_version = "1.5.22"
junit_version = "4.13.2"
@@ -119,7 +118,6 @@ dependencies {
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
}
implementation "io.gsonfire:gson-fire:$json_fire_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
}

View File

@@ -204,11 +204,6 @@
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind-version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -277,7 +272,6 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<gson-fire-version>1.9.0</gson-fire-version>
<swagger-annotations-version>1.6.3</swagger-annotations-version>
<jackson-databind-version>2.17.1</jackson-databind-version>
<retrofit-version>2.5.0</retrofit-version>
<rxjava-version>3.0.4</rxjava-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>

View File

@@ -13,11 +13,11 @@
package org.openapitools.client;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
@@ -34,14 +34,11 @@ import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;
public class JSON {
private Gson gson;
@@ -50,11 +47,6 @@ public class JSON {
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
.registerTypeSelector(Animal.class, new TypeSelector() {
@@ -293,7 +285,7 @@ public class JSON {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
@@ -303,7 +295,7 @@ public class JSON {
/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
@@ -329,7 +321,7 @@ public class JSON {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
@@ -348,7 +340,7 @@ public class JSON {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}