mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-22 02:46:59 +00:00
#2967 - [ebean-joda] Joda JSON ISO8601 format for DateMidnight includes timezone
This commit is contained in:
@@ -23,7 +23,7 @@ final class ScalarTypeJodaDateMidnight extends ScalarTypeBaseDate<DateMidnight>
|
||||
|
||||
@Override
|
||||
protected String toIsoFormat(DateMidnight value) {
|
||||
return value.toString();
|
||||
return value.toLocalDate().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package io.ebean.joda.time;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonFactory;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
import io.ebean.config.JsonConfig;
|
||||
import org.joda.time.DateMidnight;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class ScalarTypeJodaDateMidnightTest {
|
||||
|
||||
ScalarTypeJodaDateMidnight type = new ScalarTypeJodaDateMidnight(JsonConfig.Date.ISO8601);
|
||||
JsonFactory jsonFactory = new JsonFactory();
|
||||
|
||||
@Test
|
||||
void testIsoFormat() throws IOException {
|
||||
// long millis = 1674472451640L;
|
||||
JsonParser parser = jsonFactory.createParser(new StringReader("\"2023-01-23\""));
|
||||
JsonToken token = parser.nextToken();
|
||||
assertEquals(JsonToken.VALUE_STRING, token);
|
||||
DateMidnight dm = type.jsonRead(parser);
|
||||
String iso = type.toIsoFormat(dm);
|
||||
assertEquals("2023-01-23", iso);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user