targetUser.setUserMustChangePassword(sourceUser.getUserMustChangePassword());
}
+ /**
+ * Returns a formatted string from given user's locale and Date instance
+ * <p>
+ * @param user User instance
+ * @param date Date instance
+ * <p>
+ * @return A formatted string from Date instance
+ */
+ public static String formatTimestampFromUser (final User user, final Date date) {
+ // Validate parameter
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserLocale() == null) {
+ // Throw NPE
+ throw new NullPointerException("user.userLocale is null"); //NOI18N
+ } else if (null == date) {
+ // Throw NPE
+ throw new NullPointerException("date is null"); //NOI18N
+ }
+
+ // Get formatter
+ final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, user.getUserLocale());
+
+ // Now simply format the calendar's Time (not just time) field
+ final String dateTime = format.format(date.getTime());
+
+ // Return it
+ return dateTime;
+ }
+
/**
* Generates a pseudo-random user name
* <p>
// - User data
properties.setProperty("userId", Long.toString(user.getUserId())); //NOI18N
properties.setProperty("userName", user.getUserName()); //NOI18N
- properties.setProperty("userCreated", getFormattedTimestampFromUser(user, user.getUserEntryCreated())); //NOI18N
+ properties.setProperty("userCreated", formatTimestampFromUser(user, user.getUserEntryCreated())); //NOI18N
if (user.getUserEntryUpdated() != null) {
- properties.setProperty("userUpdated", getFormattedTimestampFromUser(user, user.getUserEntryUpdated())); //NOI18N
+ properties.setProperty("userUpdated", formatTimestampFromUser(user, user.getUserEntryUpdated())); //NOI18N
}
if (user.getUserConfirmKey() != null) {
properties.setProperty("userConfirmKey", user.getUserConfirmKey()); //NOI18N
properties.setProperty("userLastLockedReason", user.getUserLastLockedReason()); //NOI18N
}
if (user.getUserLastLocked() != null) {
- properties.setProperty("userLastLocked", getFormattedTimestampFromUser(user, user.getUserLastLocked())); //NOI18N
+ properties.setProperty("userLastLocked", formatTimestampFromUser(user, user.getUserLastLocked())); //NOI18N
}
properties.setProperty("userAccountStatus", user.getUserAccountStatus().toString()); //NOI18N
return properties;
}
- /**
- * Returns a formatted string from given user's locale and Date instance
- * <p>
- * @param user User instance
- * @param date Date instance
- * <p>
- * @return A formatted string from Date instance
- */
- public static String getFormattedTimestampFromUser (final User user, final Date date) {
- // Validate parameter
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("Parameter 'user' is null"); //NOI18N
- } else if (null == date) {
- // Throw NPE
- throw new NullPointerException("Parameter 'date' is null"); //NOI18N
- }
-
- // Get formatter
- final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, user.getUserLocale());
-
- // Now simply format the calendar's Time (not just time) field
- final String dateTime = format.format(date.getTime());
-
- // Return it
- return dateTime;
- }
-
/**
* No instance from this class
*/