FileDocCategorySizeDatePackage
DateType.javaAPI DocHibernate 3.2.52768Tue Dec 20 22:13:30 GMT 2005org.hibernate.type

DateType

public class DateType extends MutableType implements LiteralType, IdentifierType
date: A type that maps an SQL DATE to a Java Date.
author
Gavin King

Fields Summary
private static final String
DATE_FORMAT
Constructors Summary
Methods Summary
public java.lang.ObjectdeepCopyNotNull(java.lang.Object value)

		return new Date( ( (java.util.Date) value ).getTime() );
	
public java.lang.ObjectfromStringValue(java.lang.String xml)

		try {
			return new SimpleDateFormat(DATE_FORMAT).parse(xml);
		}
		catch (ParseException pe) {
			throw new HibernateException("could not parse XML", pe);
		}
	
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)


	        
		return rs.getDate(name);
	
public intgetHashCode(java.lang.Object x, org.hibernate.EntityMode entityMode)

		Calendar calendar = java.util.Calendar.getInstance();
		calendar.setTime( (java.util.Date) x );
		return Hibernate.CALENDAR_DATE.getHashCode(calendar, entityMode);
	
public java.lang.StringgetName()

 return "date"; 
public java.lang.ClassgetReturnedClass()

		return java.util.Date.class;
	
public booleanisEqual(java.lang.Object x, java.lang.Object y)


		if (x==y) return true;
		if (x==null || y==null) return false;

		java.util.Date xdate = (java.util.Date) x;
		java.util.Date ydate = (java.util.Date) y;
		
		if ( xdate.getTime()==ydate.getTime() ) return true;
		
		Calendar calendar1 = java.util.Calendar.getInstance();
		Calendar calendar2 = java.util.Calendar.getInstance();
		calendar1.setTime( xdate );
		calendar2.setTime( ydate );

		return Hibernate.CALENDAR_DATE.isEqual(calendar1, calendar2);
	
public java.lang.StringobjectToSQLString(java.lang.Object value, org.hibernate.dialect.Dialect dialect)

		return '\'" + new Date( ( (java.util.Date) value ).getTime() ).toString() + '\'";
	
public voidset(java.sql.PreparedStatement st, java.lang.Object value, int index)


		Date sqlDate;
		if ( value instanceof Date) {
			sqlDate = (Date) value;
		}
		else {
			sqlDate = new Date( ( (java.util.Date) value ).getTime() );
		}
		st.setDate(index, sqlDate);
	
public intsqlType()

		return Types.DATE;
	
public java.lang.ObjectstringToObject(java.lang.String xml)

		return DateFormat.getDateInstance().parse(xml);
	
public java.lang.StringtoString(java.lang.Object val)

		return new SimpleDateFormat(DATE_FORMAT).format( (java.util.Date) val );