[jOOQ/jOOQ#14866] Incorrect conversion of LocalDateTime to LocalDate during daylight saving time
This commit is contained in:
parent
3079e116c5
commit
0e4a9be380
@ -77,6 +77,7 @@ import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.OffsetTime;
|
||||
import java.time.Year;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.time.temporal.Temporal;
|
||||
import java.util.ArrayList;
|
||||
@ -1053,7 +1054,7 @@ final class Convert {
|
||||
if (LocalDateTime.class == fromClass && Timestamp.class == toClass)
|
||||
return (U) Timestamp.valueOf((LocalDateTime) from);
|
||||
else if (LocalDateTime.class == fromClass && Temporal.class.isAssignableFrom(toClass))
|
||||
return toDate(((LocalDateTime) from).toInstant(OffsetTime.now().getOffset()).toEpochMilli(), ((LocalDateTime) from).getNano(), toClass);
|
||||
return toDate(((LocalDateTime) from).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), ((LocalDateTime) from).getNano(), toClass);
|
||||
else if (LocalDate.class == fromClass && Date.class == toClass)
|
||||
return (U) Date.valueOf((LocalDate) from);
|
||||
else if (LocalTime.class == fromClass && Time.class == toClass)
|
||||
@ -1158,7 +1159,7 @@ final class Convert {
|
||||
|
||||
// Try "local" ISO date formats first
|
||||
try {
|
||||
return (U) java.sql.Timestamp.valueOf((String) from).toLocalDateTime().atOffset(OffsetDateTime.now().getOffset());
|
||||
return (U) java.sql.Timestamp.valueOf((String) from).toLocalDateTime().atZone(ZoneId.systemDefault()).toOffsetDateTime();
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
try {
|
||||
@ -1174,7 +1175,7 @@ final class Convert {
|
||||
|
||||
// Try "local" ISO date formats first
|
||||
try {
|
||||
return (U) java.sql.Timestamp.valueOf((String) from).toLocalDateTime().atOffset(OffsetDateTime.now().getOffset()).toInstant();
|
||||
return (U) java.sql.Timestamp.valueOf((String) from).toLocalDateTime().atZone(ZoneId.systemDefault()).toInstant();
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
try {
|
||||
@ -1663,7 +1664,7 @@ final class Convert {
|
||||
else if (toClass == LocalDateTime.class)
|
||||
return (X) toTimestamp(time, nanos).toLocalDateTime();
|
||||
else if (toClass == OffsetDateTime.class)
|
||||
return (X) toTimestamp(time, nanos).toLocalDateTime().atOffset(OffsetDateTime.now().getOffset());
|
||||
return (X) toTimestamp(time, nanos).toLocalDateTime().atZone(ZoneId.systemDefault()).toOffsetDateTime();
|
||||
else if (toClass == Instant.class)
|
||||
if (nanos == 0L)
|
||||
return (X) Instant.ofEpochMilli(time);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user