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

TimeType

public class TimeType extends MutableType implements LiteralType
time: A type that maps an SQL TIME to a Java java.util.Date or java.sql.Time.
author
Gavin King

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

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

		try {
			return new SimpleDateFormat(TIME_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.getTime(name);
	
public intgetHashCode(java.lang.Object x, org.hibernate.EntityMode entityMode)

		Calendar calendar = java.util.Calendar.getInstance();
		calendar.setTime( (java.util.Date) x );
		int hashCode = 1;
		hashCode = 31 * hashCode + calendar.get(Calendar.HOUR_OF_DAY);
		hashCode = 31 * hashCode + calendar.get(Calendar.MINUTE);
		hashCode = 31 * hashCode + calendar.get(Calendar.SECOND);
		hashCode = 31 * hashCode + calendar.get(Calendar.MILLISECOND);
		return hashCode;
	
public java.lang.StringgetName()

 return "time"; 
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;

		Date xdate = (Date) x;
		Date ydate = (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 calendar1.get(Calendar.HOUR_OF_DAY) == calendar2.get(Calendar.HOUR_OF_DAY)
			&& calendar1.get(Calendar.MINUTE) == calendar2.get(Calendar.MINUTE)
			&& calendar1.get(Calendar.SECOND) == calendar2.get(Calendar.SECOND)
			&& calendar1.get(Calendar.MILLISECOND) == calendar2.get(Calendar.MILLISECOND);
	
public java.lang.StringobjectToSQLString(java.lang.Object value, org.hibernate.dialect.Dialect dialect)

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


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

		return Types.TIME;
	
public java.lang.StringtoString(java.lang.Object val)

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