GregorianCalendar: is it a bug or a feature?
Is it a known feature of the GC? The GregorianCalendar implementation is a bit too complex to debug at the moment, so I decided to ask here :)
GregorianCalendar gc = new GregorianCalendar();
GregorianCalendar gc2 = new GregorianCalendar();
gc2.setTime(gc.getTime());
gc2.add(Calendar.DATE, 34);
System.out.println("Current date gc = " + gc.getTime() + ", gc2 = " + gc2.getTime());
long gc2m = gc2.getTimeInMillis();
long gcm = gc.getTimeInMillis();
long diff = gc2m - gcm;
long result = diff / 1000 / 3600 / 24;
System.out.println("Diff in days = " + result);
OUTPUT:
gc = Fri Feb 25 14:06:16 EET 2005, gc2 = Thu Mar 31 14:06:16 EEST 2005
Diff in days = 33
