Jackson's jsonformat
annotation works not quite as I expected.
Let's say in Java SimpleDateFormat
:
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
Date date = sdf.parse("1-Mar-2018");
The date
object value is 1-Mar-2018 SGT
. Which is fine because my timezone is in Singapore.
Now I have a http webservice which post a json value:
{
"filterDate": "01-Mar-2018"
}
In my bean, I annotate it with
@JsonFormat(pattern = "dd-MMM-yyyy")
public void setDeliveryDate(Date deliveryDate) {
this.deliveryDate = deliveryDate;
}
OK the value of deliveryDate
is 1-Mar-2018 UTC
.
While I do this:
@JsonFormat(pattern = "dd-MMM-yyyy", timezone="Asia/Singapore")
public void setDeliveryDate(Date deliveryDate) {
this.deliveryDate = deliveryDate;
}
It is still deserialized into 1-Mar-2018 UTC
, which I think it should be 1-Mar-2018 SGT
.
Why this behave like this?