From 122245400a8cbf72f65a206592eb15f70826ace9 Mon Sep 17 00:00:00 2001
From: Thomas <>
Date: Wed, 19 Jan 2022 14:00:06 +0100
Subject: refactor(core): change API parameters from 'Date' to 'Instant'
---
.../impl/idp/auth/data/AuthProcessDataWrapper.java | 31 ++++++++++++----------
1 file changed, 17 insertions(+), 14 deletions(-)
(limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java')
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
index 368652be..383b4535 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
@@ -21,10 +21,12 @@ package at.gv.egiz.eaaf.core.impl.idp.auth.data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.TimeZone;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -54,8 +56,8 @@ public class AuthProcessDataWrapper
}
@Override
- public Date getIssueInstant() {
- return wrapStoredObject(VALUE_ISSUEINSTANT, null, Date.class);
+ public Instant getIssueInstant() {
+ return wrapStoredObject(VALUE_ISSUEINSTANT, null, Instant.class);
}
/*
@@ -67,7 +69,7 @@ public class AuthProcessDataWrapper
@Override
public String getIssueInstantString() {
return buildDateTimeUtcString(
- wrapStoredObject(VALUE_ISSUEINSTANT, null, Date.class));
+ wrapStoredObject(VALUE_ISSUEINSTANT, null, Instant.class));
}
/*
@@ -92,7 +94,7 @@ public class AuthProcessDataWrapper
* java.lang.String)
*/
@Override
- public void setIssueInstant(final Date issueInstant) {
+ public void setIssueInstant(final Instant issueInstant) {
authProcessData.put(VALUE_ISSUEINSTANT, issueInstant);
}
@@ -347,16 +349,17 @@ public class AuthProcessDataWrapper
* yyyy-MM-dd'T'HH:mm:ss'Z'
, or null
if {@link Date} was null
*/
@Nullable
- public static String buildDateTimeUtcString(@Nullable final Date date) {
+ public static String buildDateTimeUtcString(@Nullable final Instant date) {
if (date == null) {
return null;
}
-
- final SimpleDateFormat f = new SimpleDateFormat(PATTERN_ISSUE_INSTANT);
- f.setTimeZone(TimeZone.getTimeZone("UTC"));
- return f.format(date.getTime());
-
+
+ return DateTimeFormatter
+ .ofPattern(PATTERN_ISSUE_INSTANT)
+ .withZone(ZoneId.of("UTC"))
+ .format(date);
+
}
/**
@@ -368,11 +371,11 @@ public class AuthProcessDataWrapper
* if input parameter was null
or invalid
*/
@Nullable
- public static Date buildDateTimeUtcDate(@Nullable final String date) {
+ public static Instant buildDateTimeUtcDate(@Nullable final String date) {
final SimpleDateFormat f = new SimpleDateFormat(PATTERN_ISSUE_INSTANT);
try {
- if (date != null) {
- return f.parse(date);
+ if (date != null) {
+ return f.parse(date).toInstant();
}
--
cgit v1.2.3