-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
The Instant converter is working great for me, but I'm having trouble with the LocalDate and LocalDateTime converters.
private Instant date;
private LocalDateTime date2;
private LocalDate date3;
private Instant date4;
private static Gson gson = Converters.registerAll(new GsonBuilder()).create();
public MyClass(final Instant date) {
this.date = date;
this.date2 = LocalDateTime.ofInstant(date, ZoneId.of("UTC"));
this.date3 = date2.toLocalDate();
this.date4 = date3.atStartOfDay().toInstant(ZoneOffset.UTC);
}
public String toJSON() {
return gson.toJson(this);
}When I call toJSON, the two Instants (date, date4) are serialized properly to ISO timestamps, but date2 and date3 serialize to {"date": {"year", "month", "day"}, "time": {...}} and {"year", "month", "day"} respectively.
Given the relatively simplicity of the implementation of this package, I'm not sure where the error might lie, but I just wanted to inquire here in case you have any ideas.
Metadata
Metadata
Assignees
Labels
No labels