]> git.mxchange.org Git - juser-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 5 Nov 2022 08:08:39 +0000 (09:08 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 5 Nov 2022 08:17:32 +0000 (09:17 +0100)
- 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

src/org/mxchange/jusercore/model/utils/UserUtils.java

index 3b864274c5df343139ff0e7c01aa0cdca4eb0ea1..5d98c1dc520ab0987463a37e3c6e751aca7d9899 100644 (file)
@@ -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