Files
hibernate-demo/date-time/src/main/java/com/ankurm/datetime/Legacy.java
T
asmhatreandClaude Sonnet 5.5 ef2d2aa8ea Add date-time module: Instant vs LocalDateTime vs OffsetDateTime vs ZonedDateTime round-tripped across JVM time zones on H2 and PostgreSQL
Hibernate 7.4.14.Final (plus an 8.0.0.Beta4 preview run), H2 2.5.252, PostgreSQL 17.11 in Docker.
Same-JVM and cross-zone round trips, @TimeZoneStorage modes, DST gap/overlap, precision
(precision vs secondPrecision), hibernate.jdbc.time_zone, java_time_use_direct_jdbc default flip.
Supersedes the date/time experiments of docs/13 (7.4.5); chapter 13 is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b7rnC7jppGGdHGESvy
2026-10-29 00:56:54 +00:00

50 lines
1.1 KiB
Java

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; }
}