How do I add days correctly to a date in Java?
Posted on 2014-07-31
I have to convert a method from C# to Java. The method for adding days to a date is a little different, but, even so, I can't produce the same result. Here is what I mean.
DateTime d = new DateTime(1000,1,1);
Resulting Date (not concerned with the time): July 6, 1968, which is correct.
Calendar calendar = Calendar.getInstance();
calendar.set(1000, Calendar.JANUARY, 1);
Date d = new Date();
d = calendar.getTime();
Resulting Date (not concerned with the time): July 11, 1968, which is incorrect.
What gives? What am I missing?