From a7ce3b119234afa040a11484e1a93e546e34a4a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 5 Nov 2022 09:08:39 +0100 Subject: [PATCH] Continued: - use formatTimestampFromUser() instead - also make sure that "entryCreated" is always there, if it is null, it means that an EJB has not properly set it --- .../jusercore/model/utils/UserUtils.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/org/mxchange/jusercore/model/utils/UserUtils.java b/src/org/mxchange/jusercore/model/utils/UserUtils.java index 3b86427..5d98c1d 100644 --- a/src/org/mxchange/jusercore/model/utils/UserUtils.java +++ b/src/org/mxchange/jusercore/model/utils/UserUtils.java @@ -206,6 +206,9 @@ public class UserUtils implements Serializable { if (null == user) { // Throw NPE throw new NullPointerException("user is null"); //NOI18N + } else if (user.getUserEntryCreated() == null) { + // .. and again + throw new NullPointerException("user.userEntryCreated is null"); //NOI18N } else if (user.getUserId() == null) { // Throw NPE again throw new NullPointerException("user.userId is null"); //NOI18N @@ -233,12 +236,15 @@ public class UserUtils implements Serializable { } else if (user.getUserContact().getContactPersonalTitle() == null) { // Throw NPE again throw new NullPointerException("user.userContact.contactPersonalTitle is null"); //NOI18N + } else if (user.getUserContact().getContactEntryCreated() == null) { + // .. and again + throw new NullPointerException("user.userContact.contactEntryCreated is null"); //NOI18N } // Init properties list final Properties properties = new Properties(); - // Init some vbalues with empty strings + // Init optional values with empty strings properties.setProperty("userConfirmKey", ""); //NOI18N properties.setProperty("userUpdated", ""); //NOI18N properties.setProperty("userLastLockedReason", ""); //NOI18N @@ -246,12 +252,12 @@ public class UserUtils implements Serializable { properties.setProperty("contactStreet", ""); //NOI18N properties.setProperty("contactHouseNumber", ""); //NOI18N properties.setProperty("contactCity", ""); //NOI18N - // @TODO Unfinished: - properties.setProperty("contactCountry", ""); //NOI18N + properties.setProperty("contactUpdated", ""); //NOI18N properties.setProperty("contactZipCode", ""); //NOI18N properties.setProperty("contactBirthday", ""); //NOI18N properties.setProperty("contactEmailAddress", ""); //NOI18N - properties.setProperty("contactUpdated", ""); //NOI18N + // @TODO Unfinished: + properties.setProperty("contactCountry", ""); //NOI18N // Set all: // - User data @@ -297,9 +303,11 @@ public class UserUtils implements Serializable { if (user.getUserContact().getContactEmailAddress() != null) { properties.setProperty("contactEmailAddress", user.getUserContact().getContactEmailAddress()); //NOI18N } - properties.setProperty("contactCreated", user.getUserContact().getContactEntryCreated().toString()); //NOI18N + + // Timestamps: + properties.setProperty("contactCreated", formatTimestampFromUser(user, user.getUserContact().getContactEntryCreated())); //NOI18N if (user.getUserContact().getContactEntryUpdated() != null) { - properties.setProperty("contactUpdated", user.getUserContact().getContactEntryUpdated().toString()); //NOI18N + properties.setProperty("contactUpdated", formatTimestampFromUser(user, user.getUserContact().getContactEntryUpdated())); //NOI18N } // Return it -- 2.39.5