Description of the new feature:
Two utility functions we have use for in our project is to calculate the number
of days in a given month and also to be able to add or subtract months to a
date.
Code / psuedo-code:
These works for us:
@SuppressWarnings("deprecation")
public static Date monthsAdd(Date date, int months) {
return new Date(date.getYear(), date.getMonth() + months, Math.min(daysInMonth(date, months), date.getDate()));
}
@SuppressWarnings("deprecation")
private static int daysInMonth(Date date, int months) {
return 32 - new Date(date.getYear(), date.getMonth()+ months, 32).getDate();
}
Original issue reported on code.google.com by CoB...@gmail.com on 1 Nov 2010 at 11:37
Original issue reported on code.google.com by
CoB...@gmail.com
on 1 Nov 2010 at 11:37