Java Restful API gets wrong date from POST JSON

Asked

Viewed 214 times

0

I have a java Rest API that is getting the wrong date. Javascript sends the following JSON:

{
"pessdtcad": "2018-02-24",
"dataNascimento": "1984-05-18",
"nome": "GUSTAVO DE FREITAS",
"sexo": "M",
}

And the back end shows the dates with 1 day less.

For example, when adding JSON above this is the information I get on the back:

GUSTAVO DE FREITAS;
Thu May 17 21:00:00 BRT 1984;
Fri Feb 23 21:00:00 BRT 2018

Someone’s been there and could help me?

1 answer

0

Your JSON has neither Timezone nor Culture set, so when it arrives in your backend it assumes it is in a standard Timezone and adjusts to your area.
I suggest specifying Timezone to solve your problem.

@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT-3")

You can check a similar problem being solved here.

  • Peace, this JSON is sent through an HTML POST, and when it arrives in Restful it is already with the wrong date, even putting the note above. Would there be some way for me to pass this Timezone in HTML?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.