Here is the RequestBody as JSON in SpringBoot RestController
{
"birthdate": "1991-09-30"
}
Entity:
class MyEntity {
private LocalDate birthdate;
}
JPA Repository:
public interface MyEntityRepository extends JpaRepository<MyEntity, Integer> {}
Saving entity:
myEntity.setBirthdate(LocalDate.parse(dateTime, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
Problem:
Working fine dates after 1991-09-30
and saved as it is. But dates before this are saved as one day before.
For example, dates before subtracting one day
{
"birthdate": "1991-09-29"
}
PS.
I'm using mysql Ver 8.0.21-0ubuntu0.20.04.4 for Linux on x86_64 ((Ubuntu))
try using Date this is just example :