Skip to content

Commit

Permalink
fix: let DateTime to be valid
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenglinli committed Jul 31, 2023
1 parent 3570d04 commit 6e8e078
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/sqlancer/stonedb/ast/StoneDBConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ public static class StoneDBDateConstant extends StoneDBConstant {
public String textRepr;

public StoneDBDateConstant(long val) {
long validValue = val;
// 9999-12-31 23:59:59.000999
if (validValue > 253402271999999L) {
validValue = 253402271999999L;
}
// 1000-01-01 00:00:00.000000
if (validValue < -30609820800000L) {
validValue = -30609820800000L;
}
Timestamp timestamp = new Timestamp(val);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
textRepr = dateFormat.format(timestamp);
Expand Down

0 comments on commit 6e8e078

Please sign in to comment.