Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

how to get difference between todays date and the last longin date

Hi ,

Plz help me to solve this problem -

My requirement -

1. I have to find the difference between a past date say d1 and today's date say d2.

2. If the difference between theses two dates is more than or equalto 6 months , then perform some logic .

Date Last = user.lastModified();

Date Current = new Date(System.currentTimeMillis());

int diff= Current.compareTo(Last);

How to proceed after this step .

I have done to this extent .

Please help me to get it resolved soon

Thanks in advance !!.

replied

Hi,

1. I have to find the difference between a past date say d1 and today's date say d2.

2. If the difference between theses two dates is more than or equalto 6 months , then perform some logic .

Date Last = user.lastModified();

Date Current = new Date(System.currentTimeMillis());

int diff= Current.compareTo(Last);


Date Last = user.lastModified();
Date Current = new Date(System.currentTimeMillis());

long diff = current.getTime() - last.getTime();
long days = (diff / (1000 * 60 * 60 * 24));

if( days >= 180) 
  Your logic goes here

Regards

Ayyapparaj

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question