Skip to content

Commit fb4d43b

Browse files
committed
fixes #176
1 parent 9999c50 commit fb4d43b

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

src/main/java/net/sf/jsqlparser/expression/DateValue.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,27 @@
2828
*/
2929
public class DateValue implements Expression {
3030

31-
private Date value;
31+
private Date value;
3232

33-
public DateValue(String value) {
34-
this.value = Date.valueOf(value.substring(1, value.length() - 1));
35-
}
33+
public DateValue(String value) {
34+
this.value = Date.valueOf(value.substring(1, value.length() - 1));
35+
}
3636

37-
@Override
38-
public void accept(ExpressionVisitor expressionVisitor) {
39-
expressionVisitor.visit(this);
40-
}
37+
@Override
38+
public void accept(ExpressionVisitor expressionVisitor) {
39+
expressionVisitor.visit(this);
40+
}
4141

42-
public Date getValue() {
43-
return value;
44-
}
42+
public Date getValue() {
43+
return value;
44+
}
4545

46-
public void setValue(Date d) {
47-
value = d;
48-
}
46+
public void setValue(Date d) {
47+
value = d;
48+
}
49+
50+
@Override
51+
public String toString() {
52+
return "{d '" + value.toString() + "'}";
53+
}
4954
}

src/test/java/net/sf/jsqlparser/test/select/SelectTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,10 @@ public void testTime() throws JSQLParserException {
879879
(((TimeValue) ((GreaterThan) plainSelect.getWhere()).getRightExpression()).getValue()).toString());
880880
assertStatementCanBeDeparsedAs(select, statement);
881881
}
882+
883+
public void testBetweenDate() throws JSQLParserException {
884+
assertSqlCanBeParsedAndDeparsed("SELECT * FROM mytable WHERE col BETWEEN {d '2015-09-19'} AND {d '2015-09-24'}");
885+
}
882886

883887
public void testCase() throws JSQLParserException {
884888
String statement = "SELECT a, CASE b WHEN 1 THEN 2 END FROM tab1";

0 commit comments

Comments
 (0)