Fix date issue (time lost).
This commit is contained in:
parent
a84a4ca321
commit
38c415f670
3 changed files with 39 additions and 36 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
/bin
|
||||||
|
/build
|
||||||
|
/dist
|
Binary file not shown.
|
@ -108,7 +108,7 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL");
|
statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL");
|
||||||
|
|
||||||
statement.setDate(1, dateToDate(element.getArchiveDate()));
|
statement.setTimestamp(1, dateToTimestamp(element.getArchiveDate()));
|
||||||
statement.setString(2, element.getKey());
|
statement.setString(2, element.getKey());
|
||||||
|
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
|
@ -147,7 +147,7 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=?");
|
statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=?");
|
||||||
|
|
||||||
statement.setDate(1, dateToDate(element.getArchiveDate()));
|
statement.setTimestamp(1, dateToTimestamp(element.getArchiveDate()));
|
||||||
statement.setString(2, element.getKey());
|
statement.setString(2, element.getKey());
|
||||||
statement.setString(3, element.getSubkey());
|
statement.setString(3, element.getSubkey());
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement("DELETE FROM elements WHERE ARCHIVE_DATE<?");
|
statement = connection.prepareStatement("DELETE FROM elements WHERE ARCHIVE_DATE<?");
|
||||||
|
|
||||||
statement.setDate(1, dateToDate(beforeDate));
|
statement.setTimestamp(1, dateToTimestamp(beforeDate));
|
||||||
|
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
@ -599,9 +599,9 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
element.setValue(resultSet.getString(3));
|
element.setValue(resultSet.getString(3));
|
||||||
element.setSize(resultSet.getLong(4));
|
element.setSize(resultSet.getLong(4));
|
||||||
element.setDigest(resultSet.getString(5));
|
element.setDigest(resultSet.getString(5));
|
||||||
element.setCreationDate(dateToDate(resultSet.getDate(6)));
|
element.setCreationDate(timestampToDate(resultSet.getTimestamp(6)));
|
||||||
element.setEditionDate(dateToDate(resultSet.getDate(7)));
|
element.setEditionDate(timestampToDate(resultSet.getTimestamp(7)));
|
||||||
element.setArchiveDate(dateToDate(resultSet.getDate(8)));
|
element.setArchiveDate(timestampToDate(resultSet.getTimestamp(8)));
|
||||||
|
|
||||||
//
|
//
|
||||||
result.add(element);
|
result.add(element);
|
||||||
|
@ -650,9 +650,9 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
element.setValue(resultSet.getString(3));
|
element.setValue(resultSet.getString(3));
|
||||||
element.setSize(resultSet.getLong(4));
|
element.setSize(resultSet.getLong(4));
|
||||||
element.setDigest(resultSet.getString(5));
|
element.setDigest(resultSet.getString(5));
|
||||||
element.setCreationDate(dateToDate(resultSet.getDate(6)));
|
element.setCreationDate(timestampToDate(resultSet.getTimestamp(6)));
|
||||||
element.setEditionDate(dateToDate(resultSet.getDate(7)));
|
element.setEditionDate(timestampToDate(resultSet.getTimestamp(7)));
|
||||||
element.setArchiveDate(dateToDate(resultSet.getDate(8)));
|
element.setArchiveDate(timestampToDate(resultSet.getTimestamp(8)));
|
||||||
|
|
||||||
//
|
//
|
||||||
result.add(element);
|
result.add(element);
|
||||||
|
@ -940,9 +940,9 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
result.setValue(resultSet.getString(3));
|
result.setValue(resultSet.getString(3));
|
||||||
result.setSize(resultSet.getLong(4));
|
result.setSize(resultSet.getLong(4));
|
||||||
result.setDigest(resultSet.getString(5));
|
result.setDigest(resultSet.getString(5));
|
||||||
result.setCreationDate(dateToDate(resultSet.getDate(6)));
|
result.setCreationDate(timestampToDate(resultSet.getTimestamp(6)));
|
||||||
result.setEditionDate(dateToDate(resultSet.getDate(7)));
|
result.setEditionDate(timestampToDate(resultSet.getTimestamp(7)));
|
||||||
result.setArchiveDate(dateToDate(resultSet.getDate(8)));
|
result.setArchiveDate(timestampToDate(resultSet.getTimestamp(8)));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result = null;
|
result = null;
|
||||||
|
@ -995,9 +995,9 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
result.setValue(resultSet.getString(3));
|
result.setValue(resultSet.getString(3));
|
||||||
result.setSize(resultSet.getLong(4));
|
result.setSize(resultSet.getLong(4));
|
||||||
result.setDigest(resultSet.getString(5));
|
result.setDigest(resultSet.getString(5));
|
||||||
result.setCreationDate(dateToDate(resultSet.getDate(6)));
|
result.setCreationDate(timestampToDate(resultSet.getTimestamp(6)));
|
||||||
result.setEditionDate(dateToDate(resultSet.getDate(7)));
|
result.setEditionDate(timestampToDate(resultSet.getTimestamp(7)));
|
||||||
result.setArchiveDate(dateToDate(resultSet.getDate(8)));
|
result.setArchiveDate(timestampToDate(resultSet.getTimestamp(8)));
|
||||||
} else {
|
} else {
|
||||||
result = null;
|
result = null;
|
||||||
}
|
}
|
||||||
|
@ -1046,9 +1046,9 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
element.setValue(resultSet.getString(3));
|
element.setValue(resultSet.getString(3));
|
||||||
element.setSize(resultSet.getLong(4));
|
element.setSize(resultSet.getLong(4));
|
||||||
element.setDigest(resultSet.getString(5));
|
element.setDigest(resultSet.getString(5));
|
||||||
element.setCreationDate(dateToDate(resultSet.getDate(6)));
|
element.setCreationDate(timestampToDate(resultSet.getTimestamp(6)));
|
||||||
element.setEditionDate(dateToDate(resultSet.getDate(7)));
|
element.setEditionDate(timestampToDate(resultSet.getTimestamp(7)));
|
||||||
element.setArchiveDate(dateToDate(resultSet.getDate(8)));
|
element.setArchiveDate(timestampToDate(resultSet.getTimestamp(8)));
|
||||||
|
|
||||||
//
|
//
|
||||||
result.add(element);
|
result.add(element);
|
||||||
|
@ -1097,9 +1097,9 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
element.setValue(resultSet.getString(3));
|
element.setValue(resultSet.getString(3));
|
||||||
element.setSize(resultSet.getLong(4));
|
element.setSize(resultSet.getLong(4));
|
||||||
element.setDigest(resultSet.getString(5));
|
element.setDigest(resultSet.getString(5));
|
||||||
element.setCreationDate(dateToDate(resultSet.getDate(6)));
|
element.setCreationDate(timestampToDate(resultSet.getTimestamp(6)));
|
||||||
element.setEditionDate(dateToDate(resultSet.getDate(7)));
|
element.setEditionDate(timestampToDate(resultSet.getTimestamp(7)));
|
||||||
element.setArchiveDate(dateToDate(resultSet.getDate(8)));
|
element.setArchiveDate(timestampToDate(resultSet.getTimestamp(8)));
|
||||||
|
|
||||||
//
|
//
|
||||||
result.add(element);
|
result.add(element);
|
||||||
|
@ -1585,9 +1585,9 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
statement.setString(3, element.getValue());
|
statement.setString(3, element.getValue());
|
||||||
statement.setLong(4, element.getSize());
|
statement.setLong(4, element.getSize());
|
||||||
statement.setString(5, element.getDigest());
|
statement.setString(5, element.getDigest());
|
||||||
statement.setDate(6, dateToDate(element.getCreationDate()));
|
statement.setTimestamp(6, new java.sql.Timestamp(element.getCreationDate().getTime()));
|
||||||
statement.setDate(7, dateToDate(element.getEditionDate()));
|
statement.setTimestamp(7, dateToTimestamp(element.getEditionDate()));
|
||||||
statement.setDate(8, dateToDate(element.getArchiveDate()));
|
statement.setTimestamp(8, dateToTimestamp(element.getArchiveDate()));
|
||||||
|
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
@ -1629,7 +1629,7 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
// Archive existing element.
|
// Archive existing element.
|
||||||
statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL");
|
statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL");
|
||||||
|
|
||||||
statement.setDate(1, dateToDate(element.getEditionDate()));
|
statement.setTimestamp(1, dateToTimestamp(element.getEditionDate()));
|
||||||
statement.setString(2, element.getKey());
|
statement.setString(2, element.getKey());
|
||||||
|
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
|
@ -1645,9 +1645,9 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
statement.setString(3, element.getValue());
|
statement.setString(3, element.getValue());
|
||||||
statement.setLong(4, element.getSize());
|
statement.setLong(4, element.getSize());
|
||||||
statement.setString(5, element.getDigest());
|
statement.setString(5, element.getDigest());
|
||||||
statement.setDate(6, dateToDate(element.getCreationDate()));
|
statement.setTimestamp(6, dateToTimestamp(element.getCreationDate()));
|
||||||
statement.setDate(7, dateToDate(element.getEditionDate()));
|
statement.setTimestamp(7, dateToTimestamp(element.getEditionDate()));
|
||||||
statement.setDate(8, dateToDate(element.getArchiveDate()));
|
statement.setTimestamp(8, dateToTimestamp(element.getArchiveDate()));
|
||||||
|
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
@ -1698,7 +1698,7 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
// Archive existing element.
|
// Archive existing element.
|
||||||
statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=?");
|
statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=?");
|
||||||
|
|
||||||
statement.setDate(1, dateToDate(element.getEditionDate()));
|
statement.setTimestamp(1, dateToTimestamp(element.getEditionDate()));
|
||||||
statement.setString(2, element.getKey());
|
statement.setString(2, element.getKey());
|
||||||
statement.setString(3, element.getSubkey());
|
statement.setString(3, element.getSubkey());
|
||||||
|
|
||||||
|
@ -1715,9 +1715,9 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
statement.setString(3, element.getValue());
|
statement.setString(3, element.getValue());
|
||||||
statement.setLong(4, element.getSize());
|
statement.setLong(4, element.getSize());
|
||||||
statement.setString(5, element.getDigest());
|
statement.setString(5, element.getDigest());
|
||||||
statement.setDate(6, dateToDate(element.getCreationDate()));
|
statement.setTimestamp(6, dateToTimestamp(element.getCreationDate()));
|
||||||
statement.setDate(7, dateToDate(element.getEditionDate()));
|
statement.setTimestamp(7, dateToTimestamp(element.getEditionDate()));
|
||||||
statement.setDate(8, dateToDate(element.getArchiveDate()));
|
statement.setTimestamp(8, dateToTimestamp(element.getArchiveDate()));
|
||||||
|
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
@ -1854,13 +1854,13 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
* @param source
|
* @param source
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static java.sql.Date dateToDate(final Date source) {
|
public static java.sql.Timestamp dateToTimestamp(final Date source) {
|
||||||
java.sql.Date result;
|
java.sql.Timestamp result;
|
||||||
|
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
result = null;
|
result = null;
|
||||||
} else {
|
} else {
|
||||||
result = new java.sql.Date(source.getTime());
|
result = new java.sql.Timestamp(source.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1872,7 +1872,7 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
* @param source
|
* @param source
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Date dateToDate(final java.sql.Date source) {
|
public static Date timestampToDate(final java.sql.Timestamp source) {
|
||||||
Date result;
|
Date result;
|
||||||
|
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
|
|
Loading…
Reference in a new issue