I am trying to deserialize json String date to Calendar and deserialization is working however it is not what i want.
Current Behaviour
@JsonProperty("systemDt")
@JsonFormat(Pattern="yyyy-MM-dd HH:mm:ss.SSS")
Calendar responseDateTime;
Deserializes to responseDateTime=java.util.GregorianCalendar[time=1141556400000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="UTC".....
.
I want a Simple Calendar Date of the format yyyy-MM-dd HH:mm:ss.SSS
2
Answers
tl;dr
Details
Not enough information. Your input represents a date and a time of day but lacks the context of an offset or time zone. So you cannot parse directly as a
Calendar
.Also,
Calendar
is a terribly flawed obsolete legacy class.Parse your input as a
LocalDateTime
after replacing the SPACE in the middle with aT
to comply with ISO 8601 standard.Date-time objects are not text. They do not have a format.
You should been using
LocalDateTime
property in code.eg:
output:
final: