private long getPasswordAge ( ModeledUser user ) { // If no password was set, then no time has elapsed PasswordRecordModel passwordRecord = user . getPasswordRecord ( ) ; if ( passwordRecord == null ) return 0 ; // Pull both current time and the time the password was last reset long currentTime = System . currentTimeMillis ( ) ; long lastResetTime = passwordRecord . getPasswordDate ( ) . getTime ( ) ; // Calculate the number of days elapsed since the password was last reset return TimeUnit . DAYS . convert ( currentTime - lastResetTime , TimeUnit . MILLISECONDS ) ; }
Returns the age of the given user s password in days . The age of a user s password is the amount of time elapsed since the password was last changed or reset .