|
1 | 1 | package com.uber.cadence.samples.spring.cadence;
|
2 | 2 |
|
3 |
| -import com.google.gson.JsonSerializer; |
| 3 | +import com.google.gson.JsonDeserializationContext; |
4 | 4 | import com.google.gson.JsonDeserializer;
|
5 | 5 | import com.google.gson.JsonElement;
|
6 |
| -import com.google.gson.JsonSerializationContext; |
7 |
| -import com.google.gson.JsonPrimitive; |
8 |
| -import com.google.gson.JsonDeserializationContext; |
9 | 6 | import com.google.gson.JsonParseException;
|
10 |
| - |
| 7 | +import com.google.gson.JsonPrimitive; |
| 8 | +import com.google.gson.JsonSerializationContext; |
| 9 | +import com.google.gson.JsonSerializer; |
11 | 10 | import java.lang.reflect.Type;
|
12 | 11 | import java.time.ZonedDateTime;
|
13 | 12 | import java.time.format.DateTimeFormatter;
|
14 | 13 |
|
15 |
| -public class ZonedDatetimeConverter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> { |
16 |
| - private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_DATE_TIME; |
| 14 | +public class ZonedDatetimeConverter |
| 15 | + implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> { |
| 16 | + private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_DATE_TIME; |
17 | 17 |
|
18 |
| - @Override |
19 |
| - public JsonElement serialize(ZonedDateTime src, Type type, JsonSerializationContext jsonSerializationContext) { |
20 |
| - return new JsonPrimitive(FORMATTER.format(src)); |
21 |
| - } |
| 18 | + @Override |
| 19 | + public JsonElement serialize( |
| 20 | + ZonedDateTime src, Type type, JsonSerializationContext jsonSerializationContext) { |
| 21 | + return new JsonPrimitive(FORMATTER.format(src)); |
| 22 | + } |
22 | 23 |
|
23 |
| - @Override |
24 |
| - public ZonedDateTime deserialize(JsonElement json, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { |
25 |
| - return FORMATTER.parse(json.getAsString(), ZonedDateTime::from); |
26 |
| - } |
| 24 | + @Override |
| 25 | + public ZonedDateTime deserialize( |
| 26 | + JsonElement json, Type type, JsonDeserializationContext jsonDeserializationContext) |
| 27 | + throws JsonParseException { |
| 28 | + return FORMATTER.parse(json.getAsString(), ZonedDateTime::from); |
| 29 | + } |
27 | 30 | }
|
0 commit comments