From 539804c31eb21f50c770c490cae33aaf97a2c43f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Str=C3=B6der?= Date: Tue, 23 Feb 2021 14:47:48 +0100 Subject: [PATCH] store UTC time-stamp strings to avoid time-zone issues --- .../events/logging/LastLoginEventListenerProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java b/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java index 3347bba..8f43d9c 100644 --- a/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java +++ b/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java @@ -12,7 +12,8 @@ import org.keycloak.models.UserModel; import java.util.List; import java.util.Map; -import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; public class LastLoginEventListenerProvider implements EventListenerProvider { @@ -46,7 +47,7 @@ public class LastLoginEventListenerProvider implements EventListenerProvider { } // Use current server time for login event - LocalDateTime loginTime = LocalDateTime.now(); + OffsetDateTime loginTime = OffsetDateTime.now(ZoneOffset.UTC); String loginTimeS = DateTimeFormatter.ISO_DATE_TIME.format(loginTime); user.setSingleAttribute("last-login", loginTimeS); }