on 04-07-2014 7:30 AM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.