mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
fix deprecation warning of Jackson ISO8601DateFormat
This commit is contained in:
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair;
|
||||
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
|
||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
||||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
|
||||
@@ -27,7 +27,7 @@ public class ObjectMapperProvider implements Provider<ObjectMapper> {
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||
mapper.configure(SerializationFeature.WRITE_DATES_WITH_ZONE_ID, true);
|
||||
mapper.setDateFormat(new ISO8601DateFormat());
|
||||
mapper.setDateFormat(new StdDateFormat());
|
||||
return mapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ObjectMapperProviderTest {
|
||||
|
||||
private final ObjectMapperProvider provider = new ObjectMapperProvider();
|
||||
|
||||
@Test
|
||||
void shouldFormatInstantAsISO8601() throws JsonProcessingException {
|
||||
ZoneId zone = ZoneId.of("Europe/Berlin");
|
||||
ZonedDateTime date = ZonedDateTime.of(2020, 2, 4, 15, 21, 42, 0, zone);
|
||||
|
||||
String value = provider.get().writeValueAsString(date.toInstant());
|
||||
assertThat(value).isEqualTo("\"2020-02-04T14:21:42Z\"");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user