on 03-11-2008 7:06 AM
hai all,
i have a button clicking on which i need to calculate if the difference between the current date and another date is > 7 (week).plz hel me with codings.
Thanks n Regards
Sharanya.R
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this code..
Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25);
Calendar newyears = new GregorianCalendar(1999, Calendar.JANUARY, 1);
// Determine which is earlier
boolean b = xmas.after(newyears); // false
b = xmas.before(newyears); // true
// Get difference in milliseconds
long diffMillis = newyears.getTimeInMillis() - xmas.getTimeInMillis();
// Get difference in seconds
long diffSecs = diffMillis / (1000); // 604800
// Get difference in minutes
long diffMins = diffMillis / (60 * 1000); // 10080
// Get difference in hours
long diffHours = diffMillis / (60 * 60 * 1000); // 168
// Get difference in days
long diffDays = diffMillis / (24 * 60 * 60 * 1000); // 7
System.out.println("Difference =" + diffDays);
--
Shyam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
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.