svn-gvsig-desktop / trunk / libraries / libGDBMS / src / com / hardcode / gdbms / engine / values / DateValue.java @ 1017
History | View | Annotate | Download (3.87 KB)
1 |
package com.hardcode.gdbms.engine.values; |
---|---|
2 |
|
3 |
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException; |
4 |
|
5 |
import java.sql.Date; |
6 |
import java.text.SimpleDateFormat; |
7 |
|
8 |
|
9 |
/**
|
10 |
* Wrapper sobre el tipo Date
|
11 |
*
|
12 |
* @author Fernando Gonz?lez Cort?s
|
13 |
*/
|
14 |
public class DateValue extends Value { |
15 |
private Date value; |
16 |
|
17 |
/**
|
18 |
* Creates a new DateValue object.
|
19 |
*
|
20 |
* @param d DOCUMENT ME!
|
21 |
*/
|
22 |
public DateValue(Date d) { |
23 |
value = d; |
24 |
} |
25 |
|
26 |
/**
|
27 |
* Creates a new DateValue object.
|
28 |
*/
|
29 |
public DateValue() {
|
30 |
} |
31 |
|
32 |
/**
|
33 |
* Establece el valor
|
34 |
*
|
35 |
* @param d valor
|
36 |
*/
|
37 |
public void setValue(java.util.Date d) { |
38 |
value = new Date(d.getTime()); |
39 |
} |
40 |
|
41 |
/**
|
42 |
* @see com.hardcode.gdbms.engine.values.Operations#equals(com.hardcode.gdbms.engine.values.DateValue)
|
43 |
*/
|
44 |
public Value equals(DateValue value) throws IncompatibleTypesException { |
45 |
return new BooleanValue(this.value.equals(value.value)); |
46 |
} |
47 |
|
48 |
/**
|
49 |
* @see com.hardcode.gdbms.engine.values.Operations#greater(com.hardcode.gdbms.engine.values.DateValue)
|
50 |
*/
|
51 |
public Value greater(DateValue value) throws IncompatibleTypesException { |
52 |
return new BooleanValue(this.value.compareTo(value.value) > 0); |
53 |
} |
54 |
|
55 |
/**
|
56 |
* @see com.hardcode.gdbms.engine.values.Operations#greaterEqual(com.hardcode.gdbms.engine.values.DateValue)
|
57 |
*/
|
58 |
public Value greaterEqual(DateValue value)
|
59 |
throws IncompatibleTypesException {
|
60 |
return new BooleanValue(this.value.compareTo(value.value) >= 0); |
61 |
} |
62 |
|
63 |
/**
|
64 |
* @see com.hardcode.gdbms.engine.values.Operations#less(com.hardcode.gdbms.engine.values.DateValue)
|
65 |
*/
|
66 |
public Value less(DateValue value) throws IncompatibleTypesException { |
67 |
return new BooleanValue(this.value.compareTo(value.value) < 0); |
68 |
} |
69 |
|
70 |
/**
|
71 |
* @see com.hardcode.gdbms.engine.values.Operations#lessEqual(com.hardcode.gdbms.engine.values.DateValue)
|
72 |
*/
|
73 |
public Value lessEqual(DateValue value) throws IncompatibleTypesException { |
74 |
return new BooleanValue(this.value.compareTo(value.value) <= 0); |
75 |
} |
76 |
|
77 |
/**
|
78 |
* @see com.hardcode.gdbms.engine.values.Operations#notEquals(com.hardcode.gdbms.engine.values.DateValue)
|
79 |
*/
|
80 |
public Value notEquals(DateValue value) throws IncompatibleTypesException { |
81 |
return new BooleanValue(!this.value.equals(value.value)); |
82 |
} |
83 |
|
84 |
/**
|
85 |
* @see com.hardcode.gdbms.engine.values.Operations#equals(com.hardcode.gdbms.engine.values.Value)
|
86 |
*/
|
87 |
public Value equals(Value value) throws IncompatibleTypesException { |
88 |
return value.equals(this); |
89 |
} |
90 |
|
91 |
/**
|
92 |
* @see com.hardcode.gdbms.engine.values.Operations#greater(com.hardcode.gdbms.engine.values.Value)
|
93 |
*/
|
94 |
public Value greater(Value value) throws IncompatibleTypesException { |
95 |
return value.less(this); |
96 |
} |
97 |
|
98 |
/**
|
99 |
* @see com.hardcode.gdbms.engine.values.Operations#greaterEqual(com.hardcode.gdbms.engine.values.Value)
|
100 |
*/
|
101 |
public Value greaterEqual(Value value) throws IncompatibleTypesException { |
102 |
return value.lessEqual(this); |
103 |
} |
104 |
|
105 |
/**
|
106 |
* @see com.hardcode.gdbms.engine.values.Operations#less(com.hardcode.gdbms.engine.values.Value)
|
107 |
*/
|
108 |
public Value less(Value value) throws IncompatibleTypesException { |
109 |
return value.greater(this); |
110 |
} |
111 |
|
112 |
/**
|
113 |
* @see com.hardcode.gdbms.engine.values.Operations#lessEqual(com.hardcode.gdbms.engine.values.Value)
|
114 |
*/
|
115 |
public Value lessEqual(Value value) throws IncompatibleTypesException { |
116 |
return value.greaterEqual(this); |
117 |
} |
118 |
|
119 |
/**
|
120 |
* @see com.hardcode.gdbms.engine.values.Operations#notEquals(com.hardcode.gdbms.engine.values.Value)
|
121 |
*/
|
122 |
public Value notEquals(Value value) throws IncompatibleTypesException { |
123 |
return value.notEquals(this); |
124 |
} |
125 |
public String toString() { |
126 |
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
127 |
return sdf.format(value);
|
128 |
} |
129 |
} |