The calendar uses SimpleDateFormat to specify a good format, parser error is illegal/** * Calculates the number of days between two calendar days in a manner * Which is independent the Calendar type used. * @param d1 . * @param d2 the second date. * * @return The number of days between the two dates. Zero is *   ; returned if the dates are the same, one if the dates are bsp; adjacent, etc. the order of the dates *& nbsp; does not matter, the value returned is Always >= 0. * If Calendar Types of D1 and D2 * are different, the result may is accurate . */static int Getdaysbetween (Java.util.Calendar d1, Java.util.Calendar D2) { if (D1.after (D2)) { // Swap dates So, D1 is the start and D2 is end Java.util.Calendar swap = d1;  ; D1 = d2; D2 = swap; } int days = D2.get (Java.util.Calendar.DAY_OF_YEAR)- d1.get (java.util.Calendar.DAY_OF_YEAR); int y2 = D2.get (Java.util.Calendar.YEAR); if (D1.get (Java.util.Calendar.YEAR)!= y2) { D1 = (Java.util.Calendar) d1.clone (); do { days + + d1.getactualmaximum (java.util.Calendar.DAY_ Of_year); D1.add (Java.util.Calendar.YEAR, 1); } while (D1.get ( Java.util.Calendar.YEAR)!= y2); } return days;}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service