File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed
main/java/net/sf/jsqlparser/expression
test/java/net/sf/jsqlparser/expression Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 19
19
public class TimestampValue extends ASTNodeAccessImpl implements Expression {
20
20
21
21
private Timestamp value ;
22
- private char quotation = '\'' ;
22
+ private String rawValue ;
23
+ private static final char QUOTATION = '\'' ;
23
24
24
25
public TimestampValue () {
25
26
// empty constructor
@@ -29,11 +30,7 @@ public TimestampValue(String value) {
29
30
if (value == null ) {
30
31
throw new java .lang .IllegalArgumentException ("null string" );
31
32
} else {
32
- if (value .charAt (0 ) == quotation ) {
33
- this .value = Timestamp .valueOf (value .substring (1 , value .length () - 1 ));
34
- } else {
35
- this .value = Timestamp .valueOf (value .substring (0 , value .length ()));
36
- }
33
+ setRawValue (value );
37
34
}
38
35
}
39
36
@@ -50,6 +47,19 @@ public void setValue(Timestamp d) {
50
47
value = d ;
51
48
}
52
49
50
+ public String getRawValue () {
51
+ return rawValue ;
52
+ }
53
+
54
+ public void setRawValue (String rawValue ) {
55
+ this .rawValue = rawValue ;
56
+ if (rawValue .charAt (0 ) == QUOTATION ) {
57
+ this .value = Timestamp .valueOf (rawValue .substring (1 , rawValue .length () - 1 ));
58
+ } else {
59
+ this .value = Timestamp .valueOf (rawValue .substring (0 , rawValue .length ()));
60
+ }
61
+ }
62
+
53
63
@ Override
54
64
public String toString () {
55
65
return "{ts '" + value + "'}" ;
Original file line number Diff line number Diff line change 9
9
*/
10
10
package net .sf .jsqlparser .expression ;
11
11
12
+ import static org .junit .Assert .assertEquals ;
12
13
import net .sf .jsqlparser .JSQLParserException ;
13
14
import org .junit .Test ;
14
15
@@ -25,6 +26,7 @@ public void testTimestampValue_issue525() throws JSQLParserException {
25
26
String currentDate = dateFormat .format (new Date ());
26
27
TimestampValue tv = new TimestampValue (currentDate );
27
28
System .out .println (tv .toString ());
29
+ assertEquals (currentDate , tv .getRawValue ());
28
30
}
29
31
30
32
@ Test
@@ -33,5 +35,6 @@ public void testTimestampValueWithQuotation_issue525() throws JSQLParserExceptio
33
35
String currentDate = dateFormat .format (new Date ());
34
36
TimestampValue tv = new TimestampValue ("'" + currentDate + "'" );
35
37
System .out .println (tv .toString ());
38
+ assertEquals ("'" + currentDate + "'" , tv .getRawValue ());
36
39
}
37
40
}
You can’t perform that action at this time.
0 commit comments