Skip to content

Commit

Permalink
Added Kyle's fix for ADDDATE and SUBDATE with resulting 00:00:00 bein…
Browse files Browse the repository at this point in the history
…g unexpectedly null

Signed-off-by: Guian Gumpac <guiang@bitquilltech.com>
  • Loading branch information
Guian Gumpac committed Nov 18, 2021
1 parent dd357bc commit a4d2c0c
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.sql.SQLException;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Map;
Expand Down Expand Up @@ -78,13 +79,17 @@ else if (value.charAt(23) == '+' || value.charAt(23) == '-') {
}
}

if (calendar == null) {
return Timestamp.valueOf(value);
final Timestamp ts;
if (value.length() < 11) {
ts = Timestamp.valueOf(LocalDate.parse(value).atStartOfDay());
} else {
Timestamp ts = Timestamp.valueOf(value);
return localDateTimeToTimestamp(ts.toLocalDateTime(), calendar);
ts = Timestamp.valueOf(value);
}

if (calendar == null) {
return ts;
}
return localDateTimeToTimestamp(ts.toLocalDateTime(), calendar);
} catch (IllegalArgumentException iae) {
throw stringConversionException(value, iae);
}
Expand Down

0 comments on commit a4d2c0c

Please sign in to comment.