I faced a strange problem about saving java Date
object to MySql db. Here is the error I get:
Incorrect datetime value: '1970-01-01 02:55:00' for column 'start_time' at row 1
My sql script
CREATE TABLE `schedules` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`start_time` timestamp NOT NULL,
`end_time` timestamp NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Part of my entity:
@Column(name = "start_time")
private Date startTime;
When I try to do something like
String time = "02:55"
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
scheduleEntity.setStartTime(sdf.parse(time));
repository.save(scheduleEntity);
It falls with error. But when I use "16:00"
string for parsing it works perfectly. I use Spring Boot, Spring Data with Hibernate. Can someone help me?