store UTC time-stamp strings to avoid time-zone issues

This commit is contained in:
Michael Ströder 2021-02-23 14:47:48 +01:00 committed by Thore
parent fd08207ad6
commit 539804c31e

View file

@ -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);
}