1 21 package com.db4o; 22 23 import java.util.*; 24 25 import com.db4o.foundation.*; 26 import com.db4o.reflect.*; 27 28 29 final class YDate extends YLong 30 { 31 32 private static final Date PROTO = new Date(0); 33 34 public YDate(YapStream stream) { 35 super(stream); 36 } 37 38 public Object coerce(ReflectClass claxx, Object obj) { 39 return canHold(claxx) ? obj : No4.INSTANCE; 40 } 41 42 public void copyValue(Object a_from, Object a_to){ 43 try{ 44 ((Date)a_to).setTime(((Date)a_from).getTime()); 45 }catch(Exception e){ 46 } 47 } 48 49 public Object defaultValue(){ 50 return PROTO; 51 } 52 53 public int getID(){ 54 return 10; 55 } 56 57 public boolean indexNullHandling() { 58 return true; 59 } 60 61 protected Class primitiveJavaClass(){ 62 return null; 63 } 64 65 Object primitiveNull(){ 66 return null; 67 } 68 69 Object read1(YapReader a_bytes){ 70 return new Date(readLong(a_bytes)); 71 } 72 73 public void write(Object a_object, YapReader a_bytes){ 74 if(a_object == null){ 77 a_object = new Date(0); 78 } 79 a_bytes.writeLong(((Date)a_object).getTime()); 80 } 81 82 public Object current1(){ 83 return new Date(currentLong()); 84 } 85 86 static String now(){ 87 return Platform4.format(new Date(), true); 88 } 89 90 long val(Object obj){ 91 return ((Date)obj).getTime(); 92 } 93 94 boolean isEqual1(Object obj){ 95 return obj instanceof Date && val(obj) == currentLong(); 96 } 97 98 boolean isGreater1(Object obj){ 99 return obj instanceof Date && val(obj) > currentLong(); 100 } 101 102 boolean isSmaller1(Object obj){ 103 return obj instanceof Date && val(obj) < currentLong(); 104 } 105 106 107 } 108 | Popular Tags |