java.util.Date.setMonth() should wrap around end of year.
Steps to reproduce:
Compile and run the following code
// tests setMonth()
import java.util.Date;
class setMonthTest
{
public static void main(String args[])
{
Date d1 = new Date(95, 10, 21);
System.out.println("Date " + d1);
d1.setMonth(11);
System.out.println("Date changed to Thu Dec 21 1995: " + d1);
d1.setMonth(12);
System.out.println("Date wrapped to Sun Jan 21 1996: " + d1);
}
}
Steps to reproduce:
Compile and run the following code
// tests setMonth()
import java.util.Date;
class setMonthTest
{
public static void main(String args[])
{
Date d1 = new Date(95, 10, 21);
System.out.println("Date " + d1);
d1.setMonth(11);
System.out.println("Date changed to Thu Dec 21 1995: " + d1);
d1.setMonth(12);
System.out.println("Date wrapped to Sun Jan 21 1996: " + d1);
}
}
- relates to
-
JDK-1226859 Date.setDate() does not wrap around end of month, or end of year, all platforms
- Closed