Franky
Franky

Reputation: 11

How to retrieve date from database

I have a column in my database that is of type DATE. I inserted the date via Java using the method: Date.valueOF(LocalDate.now()).

r.setRkd(Date.valueOf(LocalDate.now()));

The entry is correct because the exact date appears in the table.

    rkd
------------
 2022-03-02

The problem is that when I call the service I don't get the correct date back in the JSON, but a series of numbersenter code here.

"rkd": 1646175600000

Do you know how I can print the correct date in my JSON? Thank you in advance.

Upvotes: 0

Views: 145

Answers (1)

coses
coses

Reputation: 36

That number you are getting is the milliseconds equivalent to the date you have stored. As far as I know, dates, in general, are stored as milliseconds and displayed in different formats, e.g. YYYY-MM-DD

If you need to display it in date format there should be a method to do it depending on the specific language that you're using.

Upvotes: 1

Related Questions