summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-05-03 15:34:31 +0200
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-05-03 15:34:31 +0200
commit8aa3a0a15fece90e067be6b6af79bfaf38aa95be (patch)
tree48a3fc917c84f6df93b9bea1a89e47f1c18e6b9a /src/test/java
parentusing algorithm name map prior to search through providers (diff)
downloadUIC-barcode-8aa3a0a15fece90e067be6b6af79bfaf38aa95be.tar
UIC-barcode-8aa3a0a15fece90e067be6b6af79bfaf38aa95be.tar.gz
UIC-barcode-8aa3a0a15fece90e067be6b6af79bfaf38aa95be.tar.bz2
UIC-barcode-8aa3a0a15fece90e067be6b6af79bfaf38aa95be.tar.lz
UIC-barcode-8aa3a0a15fece90e067be6b6af79bfaf38aa95be.tar.xz
UIC-barcode-8aa3a0a15fece90e067be6b6af79bfaf38aa95be.tar.zst
UIC-barcode-8aa3a0a15fece90e067be6b6af79bfaf38aa95be.zip
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/uic/barcode/test/TimeStampTest.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/test/java/org/uic/barcode/test/TimeStampTest.java b/src/test/java/org/uic/barcode/test/TimeStampTest.java
index f03a63c..a3e8256 100644
--- a/src/test/java/org/uic/barcode/test/TimeStampTest.java
+++ b/src/test/java/org/uic/barcode/test/TimeStampTest.java
@@ -84,6 +84,32 @@ public class TimeStampTest {
assert (secondOfDay2 >= secondOfDay - 1);
assert (secondOfDay2 <= secondOfDay + 1);
-
}
+
+ @Test public void testSetDateTime() {
+ ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
+ Date dateNow = Date.from(now.toInstant());
+
+ TimeStamp ts = new TimeStamp();
+ ts.setDateTime(dateNow);
+
+ assert (ts.day.intValue() == now.get(ChronoField.DAY_OF_YEAR));
+ assert (ts.secondOfDay.intValue() == now.get(ChronoField.SECOND_OF_DAY));
+ }
+
+ @Test public void testGetTimeAsDate() {
+ ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC")).withNano(0); // we ignore nano seconds
+ Date dateNow = Date.from(now.toInstant());
+
+ TimeStamp ts = new TimeStamp();
+ ts.setDateTime(dateNow);
+
+ Date resDate = ts.getTimeAsDate();
+
+ assert (resDate.getTime() == dateNow.getTime());
+ ZonedDateTime res = ZonedDateTime.ofInstant(resDate.toInstant(), ZoneId.of("UTC")).withNano(0);
+ assert (res.compareTo(now) == 0);
+
+ }
+
}