Fix date issue.
This commit is contained in:
parent
2863aee6fa
commit
1a25aab328
1 changed files with 7 additions and 2 deletions
|
@ -186,6 +186,7 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
*/
|
||||
@Override
|
||||
public void clearArchive(final Date beforeDate) throws SQLException {
|
||||
//
|
||||
if (beforeDate == null) {
|
||||
throw new NullPointerException("beforeDate is null.");
|
||||
} else {
|
||||
|
@ -197,9 +198,9 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
//
|
||||
connection = getConnection();
|
||||
connection.setAutoCommit(true);
|
||||
statement = connection.prepareStatement("DELETE FROM elements WHERE ARCHIVE_DATE<?");
|
||||
statement = connection.prepareStatement("DELETE FROM elements WHERE ARCHIVE_DATE IS NOT NULL AND TO_SECONDS(ARCHIVE_DATE)<?");
|
||||
|
||||
statement.setTimestamp(1, dateToTimestamp(beforeDate));
|
||||
statement.setLong(1, beforeDate.getTime() / 1000);
|
||||
|
||||
statement.executeUpdate();
|
||||
|
||||
|
@ -214,6 +215,10 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
*/
|
||||
@Override
|
||||
public void clearArchive(final int maxDays) throws SQLException {
|
||||
//
|
||||
logger.debug("maxDays={}", maxDays);
|
||||
|
||||
//
|
||||
if (maxDays < 0) {
|
||||
throw new IndexOutOfBoundsException("maxDays is negative.");
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue