#2253 - Incorrect JSON format for LocalDateTime. Includes Z suffix when it should not.

This commit is contained in:
rbygrave
2021-06-17 13:26:34 +12:00
parent 37a3a51b6b
commit 7af4e166a4
2 changed files with 60 additions and 11 deletions
@@ -1,7 +1,10 @@
package io.ebeaninternal.server.type;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.config.JsonConfig;
import java.io.IOException;
import java.sql.Timestamp;
import java.sql.Types;
import java.time.Instant;
@@ -29,12 +32,37 @@ public class ScalarTypeLocalDateTime extends ScalarTypeBaseDateTime<LocalDateTim
@Override
protected String toJsonNanos(LocalDateTime value) {
return String.valueOf(convertToMillis(value));
return value.toString();
}
@Override
protected String toJsonISO8601(LocalDateTime dateTime) {
return dateTime.atZone(ZoneId.systemDefault()).toInstant().toString();
protected String toJsonISO8601(LocalDateTime value) {
return value.toString();
}
@Override
protected LocalDateTime fromJsonISO8601(String value) {
return LocalDateTime.parse(value);
}
@Override
public LocalDateTime jsonRead(JsonParser parser) throws IOException {
return LocalDateTime.parse(parser.getText());
}
@Override
public void jsonWrite(JsonGenerator writer, LocalDateTime value) throws IOException {
writer.writeString(value.toString());
}
@Override
public String formatValue(LocalDateTime value) {
return value.toString();
}
@Override
public LocalDateTime parse(String value) {
return LocalDateTime.parse(value);
}
@Override