Skip to content

Commit c2ac9d6

Browse files
committed
Fix serialization of date/time types using ISO formats
1 parent e444fda commit c2ac9d6

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

components/serialization/json/src/main/java/com/microsoft/kiota/serialization/DefaultGsonBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.time.LocalTime;
1515
import java.time.OffsetDateTime;
1616
import java.time.ZoneOffset;
17+
import java.time.format.DateTimeFormatter;
1718
import java.time.format.DateTimeParseException;
1819
import java.util.Base64;
1920

@@ -44,7 +45,7 @@ public OffsetDateTime read(JsonReader in) throws IOException {
4445

4546
@Override
4647
public void write(JsonWriter out, OffsetDateTime value) throws IOException {
47-
out.value(value.toString());
48+
out.value(value.format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
4849
}
4950
};
5051

@@ -67,7 +68,7 @@ public LocalDate read(JsonReader in) throws IOException {
6768

6869
@Override
6970
public void write(JsonWriter out, LocalDate value) throws IOException {
70-
out.value(value.toString());
71+
out.value(value.format(DateTimeFormatter.ISO_LOCAL_DATE));
7172
}
7273
};
7374

@@ -90,7 +91,7 @@ public LocalTime read(JsonReader in) throws IOException {
9091

9192
@Override
9293
public void write(JsonWriter out, LocalTime value) throws IOException {
93-
out.value(value.toString());
94+
out.value(value.format(DateTimeFormatter.ISO_LOCAL_TIME));
9495
}
9596
};
9697

0 commit comments

Comments
 (0)