Skip to content

Commit f4a1702

Browse files
committed
HHH-18532 Using 'module one day' logic to convert epoch time in milliseconds into java.sql.TiMe
1 parent a45aa9e commit f4a1702

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

hibernate-core/src/main/java/org/hibernate/type/descriptor/java/JdbcTimestampJavaType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public Object unwrap(Date value, Class type, WrapperOptions options) {
137137
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
138138
return value instanceof java.sql.Time
139139
? ( java.sql.Time ) value
140-
: new java.sql.Time( value.getTime() );
140+
: new java.sql.Time( value.getTime() % 86_400_000 );
141141
}
142142

143143
if ( Date.class.isAssignableFrom( type ) ) {

hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocalDateTimeJavaType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public <X> X unwrap(LocalDateTime value, Class<X> type, WrapperOptions options)
102102

103103
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
104104
Instant instant = value.atZone( ZoneId.systemDefault() ).toInstant();
105-
return (X) new java.sql.Time( instant.toEpochMilli() );
105+
return (X) new java.sql.Time( instant.toEpochMilli() % 86_400_000 );
106106
}
107107

108108
if ( Date.class.isAssignableFrom( type ) ) {

hibernate-core/src/main/java/org/hibernate/type/descriptor/java/OffsetDateTimeJavaType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public <X> X unwrap(OffsetDateTime offsetDateTime, Class<X> type, WrapperOptions
157157
}
158158

159159
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
160-
return (X) new java.sql.Time( offsetDateTime.toInstant().toEpochMilli() );
160+
return (X) new java.sql.Time( offsetDateTime.toInstant().toEpochMilli() % 86_400_000 );
161161
}
162162

163163
if ( Date.class.isAssignableFrom( type ) ) {

hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ZonedDateTimeJavaType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public <X> X unwrap(ZonedDateTime zonedDateTime, Class<X> type, WrapperOptions o
124124
}
125125

126126
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
127-
return (X) new java.sql.Time( zonedDateTime.toInstant().toEpochMilli() );
127+
return (X) new java.sql.Time( zonedDateTime.toInstant().toEpochMilli() % 86_400_000 );
128128
}
129129

130130
if ( Date.class.isAssignableFrom( type ) ) {

0 commit comments

Comments
 (0)