1 package org.apache.ojb.broker.accesslayer.conversions; 2 3 17 18 import java.sql.Timestamp ; 19 import java.util.Calendar ; 20 import java.util.GregorianCalendar ; 21 22 31 public class Calendar2TimestampFieldConversion implements FieldConversion 32 { 33 36 public Object javaToSql(Object source) 37 { 38 if (source instanceof Calendar ) 39 { 40 return new Timestamp (((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 Timestamp ) 56 { 57 GregorianCalendar cal = new GregorianCalendar (); 58 cal.setTime(((Timestamp ) source)); 61 return cal; 62 } 63 else 64 { 65 return source; 66 } 67 } 68 } 69 70 71 | Popular Tags |