1 package org.apache.ojb.broker.accesslayer.conversions; 2 3 17 18 import java.sql.Date ; 19 import java.util.Calendar ; 20 import java.util.GregorianCalendar ; 21 22 31 public class Calendar2DateFieldConversion implements FieldConversion 32 { 33 36 public Object javaToSql(Object source) 37 { 38 if (source instanceof Calendar ) 39 { 40 return new Date (((Calendar ) source).getTime().getTime()); 43 } 44 else 45 { 46 return source; 47 } 48 } 49 50 53 public Object sqlToJava(Object source) 54 { 55 if (source instanceof Date ) 56 { 57 GregorianCalendar cal = new GregorianCalendar (); 58 cal.setTime(((Date ) source)); 59 return cal; 60 } 61 else 62 { 63 return source; 64 } 65 } 66 } 67 68 69 | Popular Tags |