diff --git a/hibernate-java8/src/main/java/org/hibernate/internal/util/ZonedDateTimeComparator.java b/hibernate-java8/src/main/java/org/hibernate/internal/util/ZonedDateTimeComparator.java new file mode 100644 index 0000000000..6de9996d3f --- /dev/null +++ b/hibernate-java8/src/main/java/org/hibernate/internal/util/ZonedDateTimeComparator.java @@ -0,0 +1,22 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.internal.util; + +import java.io.Serializable; +import java.time.ZonedDateTime; +import java.util.Comparator; + +/** + * @author Andrea Boriero + */ +public class ZonedDateTimeComparator implements Comparator, Serializable { + public static final Comparator INSTANCE = new ZonedDateTimeComparator(); + + public int compare(ZonedDateTime one, ZonedDateTime another) { + return one.toInstant().compareTo( another.toInstant() ); + } +} diff --git a/hibernate-java8/src/main/java/org/hibernate/type/ZonedDateTimeType.java b/hibernate-java8/src/main/java/org/hibernate/type/ZonedDateTimeType.java index 1fcb37d3a0..f3c73345ad 100644 --- a/hibernate-java8/src/main/java/org/hibernate/type/ZonedDateTimeType.java +++ b/hibernate-java8/src/main/java/org/hibernate/type/ZonedDateTimeType.java @@ -13,7 +13,7 @@ import java.util.Locale; import org.hibernate.dialect.Dialect; import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.internal.util.compare.ComparableComparator; +import org.hibernate.internal.util.ZonedDateTimeComparator; import org.hibernate.type.descriptor.java.ZonedDateTimeJavaDescriptor; import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor; @@ -53,7 +53,7 @@ public class ZonedDateTimeType @Override @SuppressWarnings("unchecked") public Comparator getComparator() { - return ComparableComparator.INSTANCE; + return ZonedDateTimeComparator.INSTANCE; } @Override