Skip to content

Commit dd8bab7

Browse files
author
Raymond Augé
committed
don't use internal gson package when JDK provides alternative
Signed-off-by: Raymond Augé <raymond.auge@liferay.com>
1 parent e5c377a commit dd8bab7

File tree

1 file changed

+4
-5
lines changed
  • kubernetes/src/main/java/io/kubernetes/client/openapi

1 file changed

+4
-5
lines changed

kubernetes/src/main/java/io/kubernetes/client/openapi/JSON.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.google.gson.JsonElement;
1818
import com.google.gson.JsonParseException;
1919
import com.google.gson.TypeAdapter;
20-
import com.google.gson.internal.bind.util.ISO8601Utils;
2120
import com.google.gson.stream.JsonReader;
2221
import com.google.gson.stream.JsonWriter;
2322
import io.gsonfire.GsonFireBuilder;
@@ -28,7 +27,7 @@
2827
import java.lang.reflect.Type;
2928
import java.text.DateFormat;
3029
import java.text.ParseException;
31-
import java.text.ParsePosition;
30+
import java.time.Instant;
3231
import java.time.LocalDate;
3332
import java.time.OffsetDateTime;
3433
import java.time.format.DateTimeFormatter;
@@ -349,7 +348,7 @@ public java.sql.Date read(JsonReader in) throws IOException {
349348
if (dateFormat != null) {
350349
return new java.sql.Date(dateFormat.parse(date).getTime());
351350
}
352-
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
351+
return new java.sql.Date(Instant.from(DateTimeFormatter.ISO_INSTANT.parse(date)).toEpochMilli());
353352
} catch (ParseException e) {
354353
throw new JsonParseException(e);
355354
}
@@ -383,7 +382,7 @@ public void write(JsonWriter out, Date date) throws IOException {
383382
if (dateFormat != null) {
384383
value = dateFormat.format(date);
385384
} else {
386-
value = ISO8601Utils.format(date, true);
385+
value = DateTimeFormatter.ISO_INSTANT.format(date.toInstant());
387386
}
388387
out.value(value);
389388
}
@@ -402,7 +401,7 @@ public Date read(JsonReader in) throws IOException {
402401
if (dateFormat != null) {
403402
return dateFormat.parse(date);
404403
}
405-
return ISO8601Utils.parse(date, new ParsePosition(0));
404+
return Date.from(Instant.from(DateTimeFormatter.ISO_INSTANT.parse(date)));
406405
} catch (ParseException e) {
407406
throw new JsonParseException(e);
408407
}

0 commit comments

Comments
 (0)