1 56 package org.objectstyle.cayenne.dba.oracle; 57 58 import java.sql.CallableStatement ; 59 import java.sql.ResultSet ; 60 import java.sql.Types ; 61 import java.util.Calendar ; 62 import java.util.Date ; 63 64 import org.objectstyle.cayenne.access.types.UtilDateType; 65 66 69 public class OracleUtilDateType extends UtilDateType { 70 71 public Object materializeObject(CallableStatement cs, int index, int type) 72 throws Exception { 73 74 Object date = super.materializeObject(cs, index, type); 75 if (date == null || type != Types.TIME) { 76 return date; 77 } else { 78 return normalizeDate((Date ) date); 79 } 80 } 81 82 public Object materializeObject(ResultSet rs, int index, int type) 83 throws Exception { 84 85 Object date = super.materializeObject(rs, index, type); 86 if (date == null || type != Types.TIME) { 87 return date; 88 } else { 89 return normalizeDate((Date ) date); 90 } 91 } 92 93 97 protected Date normalizeDate(Date time) { 98 Calendar calendar = Calendar.getInstance(); 100 calendar.setTime(time); 101 calendar.set(Calendar.YEAR, 1970); 102 calendar.set(Calendar.MONTH, 0); 103 calendar.set(Calendar.DAY_OF_MONTH, 1); 104 105 return calendar.getTime(); 106 } 107 } 108 | Popular Tags |