Dangerous Date manipulation

Maybe you are expecting “20081027” output for this program? You’re wrong. This code produces “20081026”. Changing the hour (from 3:00 AM to 2:00 AM) on 26th October involves a mathematical difference of 24 + 1 hours between 26th October and 27th October. Don’t use java.util.Date to manipulate dates in Java. Use Calendar instead.