cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between 2 dates considering leap year

Former Member
0 Kudos

  Please tell me how to calculate difference between 2 dates considering leap year.

Suppose I have to substract 3 years from my current date. How should I do it?

Accepted Solutions (1)

Accepted Solutions (1)

govardan_raj
Contributor
0 Kudos

Hi naga,

what exactly u wanted , like you want to know the difference between two dates in form of days ? or just the date 3 years before from current date . in this case use the above code if you want to know the date 3 years before a given date xxxx then code is slightlly different

use cal.set(year,month,date) i.e  cal.add(2010,10,23) and then cal.add(calendar.year,-3) .

Regards

Govardan


Answers (1)

Answers (1)

govardan_raj
Contributor
0 Kudos

hi Naga,

use the below code

 

Calendar cal = Calendar.getInstance();

cal.add(Calendar.YEAR,-3);

Date subtractdate = new Date(cal.getTimeInMillis());

wdComponentAPI.getMessageManager().reportSuccess(""+subtractdate);

Regards

Govardan Raj