Title: RE: [jdjlist] RE: Expiration date.

Calendar cal1 = Calendar.getInstance()
cal1.setTime(new Date());

Calendar cal2 = Calendar.getInstance()
cal2.setTime(pwdDate);

cal2.add(Calendar.DATE,30);

If (cal2.before(cal1)) // not expired
-----Original Message-----
From: Cohan, Sean [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 20, 2002 11:30 AM
To: JDJList
Subject: [jdjlist] RE: Expiration date.


Can you provide a samplet?  Thanks.

-----Original Message-----
From: Nahid, Nazneen (CORP, Consultant) [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 20, 2002 2:22 PM
To: JDJList
Subject: [jdjlist] RE: Expiration date.


Use Calendar rather than Date  for all calculation. and do all calcualtion with date rather than in long.

-----Original Message-----
From: Cohan, Sean [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 20, 2002 2:20 PM
To: JDJList
Subject: [jdjlist] Expiration date.


I'm trying to write an equation that lets me know if the current date is more than 30 days after a previous date, but it's not working out.  Can someone show me the way?  Here is what I have.

public boolean isPasswordExpired() {
        long passwordTs = getPasswordTs().getTime();    // getPasswordTs
returns a java.util.Date
        long nowTs = new Date().getTime();

        int expirationDays = 30;

                double dayDifference =
                        (nowTs - passwordTs / (double) TimeStamp.MILLISECONDS_PER_DAY); // 24 * 60 * 60 * 1000.

        if (dayDifference < expirationDays)
                return true;   
        return false;
}


getPasswordDt() is returning the 07/07/2002.

I get output similar to the following using printlns:

nowTs =  1032545252875
passwordTs = 1026057600000
nowTs - passwordTs / millis per day  = 1.0325452409993334E12

Any clues?

Thanks.

To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm Information contained in this email message is intended only for
use of the individual or entity named above. If the reader of
this message is not the intended recipient, or the employee or
agent responsible to deliver it to the intended recipient, you
are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you
have received this communication in error, please immediately
notify the [EMAIL PROTECTED] and destroy the original
message.

Reply via email to