I got a strange error while running some code. Here is a simple version to demonstrate the same.
public class DateTest {
public static void main(String[] args) {
LocalDate decLast = LocalDate.of(2015, 12, 31);
LocalDate novLast = LocalDate.of(2015, 11, 30);
LocalDate octLast = LocalDate.of(2015, 10, 31);
System.out.println(decLast+" "+novLast+" "+octLast);
System.out.println(decLast.format(DateTimeFormatter.ofPattern("dd M YY"))+" "
+novLast.format(DateTimeFormatter.ofPattern("dd M YY"))+" "
+octLast.format(DateTimeFormatter.ofPattern("dd M YY")));
}
}
This returned the following results:
2015-12-31 2015-11-30 2015-10-31
31/12/16 30/11/15 31/10/15
One way or another, December 31, 2015 was transformed into December 31, 2016. I wrote a for loop to do the same in different years, and found that there was variation for many years. The error does not exist for any dates below December 26th. Is this a mistake or am I missing something?
source
share