Skip to content

Commit c6b1f9e

Browse files
authored
Merge pull request #2187 from rotty3000/issue2186
don't use internal gson package when JDK provides alternative
2 parents 88a4953 + 1710835 commit c6b1f9e

File tree

1 file changed

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

1 file changed

+5
-5
lines changed

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

Lines changed: 5 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,8 @@ 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(
352+
Instant.from(DateTimeFormatter.ISO_INSTANT.parse(date)).toEpochMilli());
353353
} catch (ParseException e) {
354354
throw new JsonParseException(e);
355355
}
@@ -383,7 +383,7 @@ public void write(JsonWriter out, Date date) throws IOException {
383383
if (dateFormat != null) {
384384
value = dateFormat.format(date);
385385
} else {
386-
value = ISO8601Utils.format(date, true);
386+
value = DateTimeFormatter.ISO_INSTANT.format(date.toInstant());
387387
}
388388
out.value(value);
389389
}
@@ -402,7 +402,7 @@ public Date read(JsonReader in) throws IOException {
402402
if (dateFormat != null) {
403403
return dateFormat.parse(date);
404404
}
405-
return ISO8601Utils.parse(date, new ParsePosition(0));
405+
return Date.from(Instant.from(DateTimeFormatter.ISO_INSTANT.parse(date)));
406406
} catch (ParseException e) {
407407
throw new JsonParseException(e);
408408
}

0 commit comments

Comments
 (0)