import java.io.Serializable;
import java.security.SecureRandom;
+import java.text.DateFormat;
import java.text.MessageFormat;
+import java.util.Calendar;
import java.util.Properties;
import java.util.Random;
import java.util.regex.Matcher;
// - User data
properties.setProperty("userId", Long.toString(user.getUserId())); //NOI18N
properties.setProperty("userName", user.getUserName()); //NOI18N
- properties.setProperty("userCreated", user.getUserCreated().toString()); //NOI18N
+ properties.setProperty("userCreated", getFormattedTimestampFromUser(user, user.getUserCreated())); //NOI18N
if (user.getUserUpdated() != null) {
- properties.setProperty("contactUpdated", user.getUserUpdated().toString()); //NOI18N
+ properties.setProperty("userUpdated", getFormattedTimestampFromUser(user, user.getUserUpdated())); //NOI18N
}
if (user.getUserConfirmKey() != null) {
properties.setProperty("userConfirmKey", user.getUserConfirmKey()); //NOI18N
if (user.getUserLastLockedReason() != null) {
properties.setProperty("userLastLockedReason", user.getUserLastLockedReason()); //NOI18N
}
+ if (user.getUserLastLocked() != null) {
+ properties.setProperty("userLastLocked", getFormattedTimestampFromUser(user, user.getUserLastLocked())); //NOI18N
+ }
properties.setProperty("userAccountStatus", user.getUserAccountStatus().toString()); //NOI18N
// - Contact data
return properties;
}
+ /**
+ * Returns a formatted string from given user's locale and Calendar instance
+ * <p>
+ * @param user User instance
+ * @param calendar Calendar instance
+ * <p>
+ * @return A formatted string from Calendar instance
+ */
+ public static String getFormattedTimestampFromUser (final User user, final Calendar calendar) {
+ // Get formatter
+ DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, user.getUserLocale());
+
+ // Now simply format the calendar's Time (not just time) field
+ String dateTime = format.format(calendar.getTime());
+
+ // Return it
+ return dateTime;
+ }
+
/**
* Checks if password from container matches the updatedUser's password
* <p>