package com.ankurm.datetime; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; import java.time.Duration; import java.time.Year; import java.time.YearMonth; import java.util.Date; /** Types people ask about: a java.util.Date with no @Temporal, and the java.time types with no SQL twin. */ @Entity @Table(name = "legacy") public class Legacy { @Id private Long id; /** No @Temporal annotation at all. */ @Column(name = "util_date_col") private Date utilDate; @Column(name = "year_col") private Year year; @Column(name = "year_month_col") private YearMonth yearMonth; @Column(name = "duration_col") private Duration duration; protected Legacy() { } public Legacy(Long id, Date utilDate, Year year, YearMonth yearMonth, Duration duration) { this.id = id; this.utilDate = utilDate; this.year = year; this.yearMonth = yearMonth; this.duration = duration; } public Date getUtilDate() { return utilDate; } public Year getYear() { return year; } public YearMonth getYearMonth() { return yearMonth; } public Duration getDuration() { return duration; } }