None of the strings I use in JSON are able to be deserialized into a LocalDateTime
with Spring Boot and Jackson 310. I tried all of the following:
- 2017-05-04T11:28:56.816
- 2014-01-01T00:00:00
- 2017-09-29 00:00:00
But none work. My DTO is simple and I tried:
@ApiModel
@Validated
public class DateRange implements Serializable
{
@ApiModelProperty
@NotNull
@JsonFormat( shape = JsonFormat.Shape.ANY, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT" )
protected LocalDateTime start;
@ApiModelProperty
@NotNull
@JsonFormat( shape = JsonFormat.Shape.ANY, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT" )
protected LocalDateTime end;
public DateRange()
{
}
public LocalDateTime getStart()
{
return start;
}
public void setStart(LocalDateTime start)
{
this.start = start;
}
public LocalDateTime getEnd()
{
return end;
}
public void setEnd(LocalDateTime end)
{
this.end = end;
}
@Override
public boolean equals(Object o)
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
DateRange range = ( DateRange ) o;
return Objects.equals( start, range.start ) && Objects.equals( end, range.end );
}
@Override
public int hashCode()
{
return Objects.hash( start, end );
}
}
The JSON I submitted was:
{
"start": "2017-09-29 00:00:00",
"end": "2017-09-29 00:00:00"
}
I also tried all the diff versions posted up above in the bulleted list.
What am I doing wrong?