@Jsonformat is an annotation belong to package Jackson-databind
It is used on a Getter method to format how the Date instance is serialized. By default, a Date instance is serialized as a number ref. to the begging of the time counting.
As using @JsonFormat, the time output is formatted ref. to a default time-zone or a locale. Normally it is the GMT time zone.
@Getter
@Setter
@AllArgsConstructor
@Builder
public class RoomReservation {
private Long roomId;
private Long guestId;
private String roomName;
private String roomNumber;
private String firstName;
private String lastName;
@Getter(AccessLevel.NONE)
private Date date;
@JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING, timezone = "Europe/Copenhagen")
public Date getDate() {
return date;
}
}
No comments:
Post a Comment