diff --git a/.classpath b/.classpath index 1dbc32b..35edb50 100644 --- a/.classpath +++ b/.classpath @@ -22,5 +22,6 @@ + diff --git a/bin/fr/devinsy/sikevadb/Element.class b/bin/fr/devinsy/sikevadb/Element.class index c1f8954..a831e1a 100644 Binary files a/bin/fr/devinsy/sikevadb/Element.class and b/bin/fr/devinsy/sikevadb/Element.class differ diff --git a/bin/fr/devinsy/sikevadb/FileSikevaDB.class b/bin/fr/devinsy/sikevadb/FileSikevaDB.class index d66033d..2028a3d 100644 Binary files a/bin/fr/devinsy/sikevadb/FileSikevaDB.class and b/bin/fr/devinsy/sikevadb/FileSikevaDB.class differ diff --git a/bin/fr/devinsy/sikevadb/SQLSikevaDB.class b/bin/fr/devinsy/sikevadb/SQLSikevaDB.class index 8e3c2c8..92bdb17 100644 Binary files a/bin/fr/devinsy/sikevadb/SQLSikevaDB.class and b/bin/fr/devinsy/sikevadb/SQLSikevaDB.class differ diff --git a/bin/fr/devinsy/sikevadb/SikevaDB.class b/bin/fr/devinsy/sikevadb/SikevaDB.class index 9edca4e..7862bbb 100644 Binary files a/bin/fr/devinsy/sikevadb/SikevaDB.class and b/bin/fr/devinsy/sikevadb/SikevaDB.class differ diff --git a/lib/joda-time-2.3-sources.jar b/lib/joda-time-2.3-sources.jar new file mode 100644 index 0000000..a2dda2e Binary files /dev/null and b/lib/joda-time-2.3-sources.jar differ diff --git a/lib/joda-time-2.3.jar b/lib/joda-time-2.3.jar new file mode 100644 index 0000000..9dce4f9 Binary files /dev/null and b/lib/joda-time-2.3.jar differ diff --git a/src/fr/devinsy/sikevadb/Element.java b/src/fr/devinsy/sikevadb/Element.java index 21f5adf..2d6ad4c 100644 --- a/src/fr/devinsy/sikevadb/Element.java +++ b/src/fr/devinsy/sikevadb/Element.java @@ -15,9 +15,8 @@ */ package fr.devinsy.sikevadb; -import java.util.Date; - import org.apache.commons.codec.digest.DigestUtils; +import org.joda.time.DateTime; /** * @@ -26,9 +25,9 @@ import org.apache.commons.codec.digest.DigestUtils; */ public class Element { - private Date creationDate; - private Date editionDate; - private Date archiveDate; + private DateTime creationDate; + private DateTime editionDate; + private DateTime archiveDate; private String key; private String subkey; private long size; @@ -59,14 +58,14 @@ public class Element { * */ public void archive() { - this.archiveDate = new Date(); + this.archiveDate = DateTime.now(); } - public Date getArchiveDate() { + public DateTime getArchiveDate() { return archiveDate; } - public Date getCreationDate() { + public DateTime getCreationDate() { return creationDate; } @@ -74,7 +73,7 @@ public class Element { return digest; } - public Date getEditionDate() { + public DateTime getEditionDate() { return editionDate; } @@ -94,24 +93,20 @@ public class Element { return value; } - public void setArchiveDate(final Date archiveDate) { - if (archiveDate == null) { - this.archiveDate = null; - } else { - this.archiveDate = (Date) archiveDate.clone(); - } + public void setArchiveDate(final DateTime date) { + this.archiveDate = date; } - public void setCreationDate(final Date creationDate) { - this.creationDate = (Date) creationDate.clone(); + public void setCreationDate(final DateTime date) { + this.creationDate = date; } public void setDigest(final String digest) { this.digest = digest; } - public void setEditionDate(final Date editionDate) { - this.editionDate = (Date) editionDate.clone(); + public void setEditionDate(final DateTime date) { + this.editionDate = date; } public void setKey(final String key) { @@ -135,7 +130,7 @@ public class Element { setValue(value); // - this.editionDate = new Date(); + this.editionDate = DateTime.now(); // if (value == null) { diff --git a/src/fr/devinsy/sikevadb/FileSikevaDB.java b/src/fr/devinsy/sikevadb/FileSikevaDB.java index d493560..b946eb2 100644 --- a/src/fr/devinsy/sikevadb/FileSikevaDB.java +++ b/src/fr/devinsy/sikevadb/FileSikevaDB.java @@ -16,7 +16,8 @@ package fr.devinsy.sikevadb; import java.io.File; -import java.util.Date; + +import org.joda.time.DateTime; import fr.devinsy.util.StringList; @@ -61,7 +62,7 @@ public class FileSikevaDB implements SikevaDB { } @Override - public void clearArchive(final Date beforeDate) throws Exception { + public void clearArchive(final DateTime beforeDate) throws Exception { // TODO Auto-generated method stub } diff --git a/src/fr/devinsy/sikevadb/SQLSikevaDB.java b/src/fr/devinsy/sikevadb/SQLSikevaDB.java index f61e883..62dbd4c 100644 --- a/src/fr/devinsy/sikevadb/SQLSikevaDB.java +++ b/src/fr/devinsy/sikevadb/SQLSikevaDB.java @@ -29,6 +29,7 @@ import javax.naming.NamingException; import javax.sql.DataSource; import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -107,7 +108,7 @@ public class SQLSikevaDB implements SikevaDB { connection.setAutoCommit(true); statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL"); - statement.setTimestamp(1, dateToTimestamp(element.getArchiveDate())); + statement.setTimestamp(1, toTimestamp(element.getArchiveDate())); statement.setString(2, element.getKey()); statement.executeUpdate(); @@ -146,7 +147,7 @@ public class SQLSikevaDB implements SikevaDB { connection.setAutoCommit(true); statement = connection.prepareStatement("UPDATE elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=?"); - statement.setTimestamp(1, dateToTimestamp(element.getArchiveDate())); + statement.setTimestamp(1, toTimestamp(element.getArchiveDate())); statement.setString(2, element.getKey()); statement.setString(3, element.getSubkey()); @@ -185,7 +186,7 @@ public class SQLSikevaDB implements SikevaDB { * {@inheritDoc} */ @Override - public void clearArchive(final Date beforeDate) throws SQLException { + public void clearArchive(final DateTime beforeDate) throws SQLException { // if (beforeDate == null) { throw new NullPointerException("beforeDate is null."); @@ -198,9 +199,9 @@ public class SQLSikevaDB implements SikevaDB { // connection = getConnection(); connection.setAutoCommit(true); - statement = connection.prepareStatement("DELETE FROM elements WHERE ARCHIVE_DATE IS NOT NULL AND TO_SECONDS(ARCHIVE_DATE)