VKP
VKP

Reputation: 658

Why Date field is coming with Character T in JPA

Hi I am trying to retrieve and Save Date from Oracle Table using JPA . The column type is DATE in Oracle. In JPA entity i configured as

@Column(name = "NOTE_DATE")
private Date  noteDate;

In Json why i am getting the date with a T character . Eventhough its not saving that (T)character ins DB why its asking for date as

Successful Save

"noteDate": "2021-11-01T20:00:05"

Failure Save

"noteDate": "2021-11-01 20:00:05"

Upvotes: 0

Views: 76

Answers (1)

Ahmed HENTETI
Ahmed HENTETI

Reputation: 1128

The 2021-11-01T20:00:05 date representation is generated by your JSON serializer which converts your Date to String and not by JPA. By default, Spring uses Jackson as JSON serializer which converts Date to its ISO 8601 representation.

For your error when you try to save your object using

"noteDate": "2021-11-01 20:00:05"

For me, it is a deserialization problem: Jackson can not convert your JSON to your Java object.

Upvotes: 2

Related Questions