1
//$Id: TimeZoneType.java 7825 2005-08-10 20:23:55Z oneovthafew $
2
package org.hibernate.type;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
6
import java.sql.SQLException;
7
import java.util.TimeZone;
9
import org.hibernate.EntityMode;
10
import org.hibernate.Hibernate;
11
import org.hibernate.HibernateException;
12
import org.hibernate.dialect.Dialect;
15
* <tt>timezone</tt>: A type that maps an SQL VARCHAR to a
16
* <tt>java.util.TimeZone</tt>
17
* @see java.util.TimeZone
20
public class TimeZoneType extends ImmutableType implements LiteralType {
22
public Object get(ResultSet rs, String name)
23
throws HibernateException, SQLException {
24
String id = (String) Hibernate.STRING.nullSafeGet(rs, name);
25
return (id==null) ? null : TimeZone.getTimeZone(id);
29
public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
30
Hibernate.STRING.set(st, ( (TimeZone) value ).getID(), index);
33
public int sqlType() {
34
return Hibernate.STRING.sqlType();
37
public String toString(Object value) throws HibernateException {
38
return ( (TimeZone) value ).getID();
41
public int compare(Object x, Object y, EntityMode entityMode) {
42
return ( (TimeZone) x ).getID().compareTo( ( (TimeZone) y ).getID() );
45
public Object fromStringValue(String xml) throws HibernateException {
46
return TimeZone.getTimeZone(xml);
49
public Class getReturnedClass() {
50
return TimeZone.class;
53
public String getName() {
57
public String objectToSQLString(Object value, Dialect dialect) throws Exception {
58
return ( (LiteralType) Hibernate.STRING ).objectToSQLString(
59
( (TimeZone) value ).getID(), dialect