HHH-10372 - Add ZonedDateTimeComparator
This commit is contained in:
parent
e261506d61
commit
f58c8eba9c
|
@ -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() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,7 @@ import java.util.Locale;
|
||||||
|
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
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.java.ZonedDateTimeJavaDescriptor;
|
||||||
import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class ZonedDateTimeType
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Comparator<ZonedDateTime> getComparator() {
|
public Comparator<ZonedDateTime> getComparator() {
|
||||||
return ComparableComparator.INSTANCE;
|
return ZonedDateTimeComparator.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue