1 package jodd.datetime.converters; 2 3 import java.util.Date; 4 5 import jodd.datetime.DateTimeStamp; 6 import jodd.datetime.JDateTime; 7 8 public class DateConverter implements jodd.datetime.JdtConverter { 9 10 public void load(JDateTime gt, Object o) { 11 if (o instanceof Date) { 12 Date d = (Date) o; 13 gt.set(1900 + d.getYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()); 14 } 15 } 16 17 public Object get(JDateTime gt) { 18 Date d = new Date(); 19 store(gt, d); 20 return d; 21 } 22 23 24 public void store(JDateTime gt, Object o) { 25 if (o instanceof Date) { 26 DateTimeStamp time = gt.getDateTimeStamp(); 27 Date d = (Date) o; 28 d.setYear(time.year - 1900); 29 d.setMonth(time.month - 1); 30 d.setDate(time.day); 31 d.setHours(time.hour); 32 d.setMinutes(time.minute); 33 d.setSeconds((int)time.second); 34 } 35 } 36 37 } 38 | Popular Tags |