My heart is bleeding internally after having to go so deep to subtract two dates to calculate the span in number of days:
GregorianCalendar c1 = new GregorianCalendar();
GregorianCalendar c2 = new GregorianCalendar();
c1.set(2000, 1, 1);
c2.set(2010,1, 1);
long span = c2.getTimeInMillis() - c1.getTimeInMillis();
GregorianCalendar c3 = new GregorianCalendar();
c3.setTimeInMillis(span);
long numberOfMSInADay = 1000*60*60*24;
System.out.println(c3.getTimeInMillis() / numberOfMSInADay); //3653
where it's only 2 lines of code in .NET, or any modern language you name.
Is this atrocious of java? Or is there a hidden method I should know?
Instead of using GregorianCalendar, is it okay to use Date class in util? If so, should I watch out for subtle things like the year 1970?
Thanks