HHH-10372 - Add ZonedDateTimeComparator

This commit is contained in:
Andrea Boriero 2016-01-15 14:32:40 +00:00
parent 4b80e154e2
commit 75fdf70704
2 changed files with 24 additions and 2 deletions

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<ZonedDateTime>, Serializable {
public static final Comparator INSTANCE = new ZonedDateTimeComparator();
public int compare(ZonedDateTime one, ZonedDateTime another) {
return one.toInstant().compareTo( another.toInstant() );
}
}

View File

@ -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<ZonedDateTime> getComparator() {
return ComparableComparator.INSTANCE;
return ZonedDateTimeComparator.INSTANCE;
}
@Override