на HTML /JavaScript Date Format.
Код: Выделить всё
public class LocalDateTimeSerializer implements JsonSerializer {
@Override
public JsonElement serialize(LocalDateTime localDateTime, Type type, JsonSerializationContext jsonSerializationContext) {
Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
Date date = Date.from(instant);
return new JsonPrimitive(date.getTime());
}
}
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer());
Gson gson = gsonBuilde
< /code>
Затем в JavaScript я создаю объект даты, используя эту марку времени.>
Подробнее здесь: https://stackoverflow.com/questions/219 ... -using-gso