org.hibernate.type.CalendarType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
/*
* 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.type;
import java.util.Calendar;
import java.util.Comparator;
import java.util.GregorianCalendar;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.java.CalendarTypeDescriptor;
import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor;
/**
* A type that maps between {@link java.sql.Types#TIMESTAMP TIMESTAMP} and {@link Calendar}
*
* @author Gavin King
* @author Steve Ebersole
*/
public class CalendarType
extends AbstractSingleColumnStandardBasicType
implements VersionType {
public static final CalendarType INSTANCE = new CalendarType();
public CalendarType() {
super( TimestampTypeDescriptor.INSTANCE, CalendarTypeDescriptor.INSTANCE );
}
@Override
public String getName() {
return "calendar";
}
@Override
public String[] getRegistrationKeys() {
return new String[] { getName(), Calendar.class.getName(), GregorianCalendar.class.getName() };
}
@Override
public Calendar next(Calendar current, SharedSessionContractImplementor session) {
return seed( session );
}
@Override
public Calendar seed(SharedSessionContractImplementor session) {
return Calendar.getInstance();
}
@Override
public Comparator getComparator() {
return getJavaTypeDescriptor().getComparator();
}
}