1 | package org.cardanofoundation.explorer.api.config; | |
2 | ||
3 | import java.io.IOException; | |
4 | import java.time.LocalDateTime; | |
5 | import java.time.format.DateTimeFormatter; | |
6 | ||
7 | import com.fasterxml.jackson.core.JsonGenerator; | |
8 | import com.fasterxml.jackson.databind.JsonSerializer; | |
9 | import com.fasterxml.jackson.databind.SerializerProvider; | |
10 | ||
11 | public class JackSonDateTimeSerializer extends JsonSerializer<LocalDateTime> { | |
12 | ||
13 | public static final String DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss"; | |
14 | ||
15 | /** | |
16 | * Method that can be called to ask implementation to serialize values of type this serializer | |
17 | * handles. | |
18 | * | |
19 | * @param value Value to serialize; can <b>not</b> be null. | |
20 | * @param gen Generator used to output resulting Json content | |
21 | * @param serializers Provider that can be used to get serializers for serializing Objects value | |
22 | * contains, if any. | |
23 | */ | |
24 | @Override | |
25 | public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers) | |
26 | throws IOException { | |
27 |
1
1. serialize : removed call to com/fasterxml/jackson/core/JsonGenerator::writeString → NO_COVERAGE |
gen.writeString(value.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT))); |
28 | } | |
29 | } | |
Mutations | ||
27 |
1.1 |