on 12-10-2008 5:02 AM
Hi All,
I have two date fields start date and end date.I need to calculate the difference between two dates ie end date - start date.
How to do this in webdynpro .
Hi ,
There is nothing special in webdynpro to manupulate two dates , u just need to write simple java code.
Check the following code
import java.util.Calendar;
Calendar calendar1 = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
calendar1.set(2007, 01, 10);
calendar2.set(2007, 07, 01);
long milliseconds1 = calendar1.getTimeInMillis();
long milliseconds2 = calendar2.getTimeInMillis();
long diff = milliseconds2 - milliseconds1;
long diffSeconds = diff / 1000;
long diffMinutes = diff / (60 * 1000);
long diffHours = diff / (60 * 60 * 1000);
long diffDays = diff / (24 * 60 * 60 * 1000);
Output
Time in milliseconds: = diff
Time in seconds: = diffSeconds
Time in minutes: = diffMinutes
Time in hours: = diffHours
Time in days: = diffDays
Regards,
Piyush
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.