summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode
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/main/java/org/uic/barcode
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/main/java/org/uic/barcode')
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/TimeStamp.java49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/main/java/org/uic/barcode/dynamicContent/fdc1/TimeStamp.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/TimeStamp.java
index 2f54da3..3095ea5 100644
--- a/src/main/java/org/uic/barcode/dynamicContent/fdc1/TimeStamp.java
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/TimeStamp.java
@@ -1,8 +1,5 @@
package org.uic.barcode.dynamicContent.fdc1;
-import java.time.Instant;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
@@ -104,26 +101,26 @@ public class TimeStamp {
* @return the date and time of content creation in UTC
*/
public Date getTimeAsDate() {
-
- ZonedDateTime now = Instant.now().atZone(ZoneOffset.UTC);
- int dayOfYear = now.getDayOfYear();
-
+
+ Calendar now = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ int dayOfYear = now.get(Calendar.DAY_OF_YEAR);
+
if (dayOfYear - day.intValue() > 250) {
- now = now.plusYears(1);
+ now.add(Calendar.YEAR, 1);
}
if (day.intValue() - dayOfYear > 250) {
- now = now.minusYears(1);
+ now.add(Calendar.YEAR, -1);
}
- now = now.withDayOfYear(1);
- now = now.withSecond(0);
- now = now.withHour(0);
- now = now.withMinute(0);
- now = now.withNano(0);
- now = now.withDayOfYear(day.intValue());
- now = now.plusSeconds(secondOfDay);
-
- return Date.from(now.toInstant());
+ now.set(Calendar.DAY_OF_YEAR, 1);
+ now.set(Calendar.SECOND, 0);
+ now.set(Calendar.HOUR_OF_DAY, 0);
+ now.set(Calendar.MINUTE, 0);
+ now.set(Calendar.MILLISECOND, 0);
+ now.set(Calendar.DAY_OF_YEAR, day.intValue());
+ now.add(Calendar.SECOND, secondOfDay.intValue());
+
+ return now.getTime();
}
@@ -134,13 +131,15 @@ public class TimeStamp {
*/
public void setDateTime(Date dateUTC) {
- ZonedDateTime date = dateUTC.toInstant().atZone(ZoneOffset.UTC);
-
- day = (long) date.getDayOfYear();
-
- secondOfDay = (long) date.getSecond();
- secondOfDay = secondOfDay + 60 * (long) date.getMinute();
- secondOfDay = secondOfDay + 60 * 60 * (long) date.getHour();
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ c.setTime(dateUTC);
+
+ day = (long) c.get(Calendar.DAY_OF_YEAR);
+
+ secondOfDay = (long) c.get(Calendar.SECOND);
+ secondOfDay += 60L * c.get(Calendar.MINUTE);
+ secondOfDay += 3600L * c.get(Calendar.HOUR_OF_DAY);
+
}