Here's some code that gives 419, the same thing I worked out by hand:
import java.util.*;
public class gctest {
public static void main(String[] argv) {
Calendar a, b;
a=new GregorianCalendar(1991,01,15); // 1991-FEB-15
b=new GregorianCalendar(1992,03,10); // 1992-APR-10
System.out.println((b.getTime().getTime()-a.getTime().getTime())/(1000*60*60*24));
}
}
Perhaps you forgot to subtract 1 for the month numbers since in Java January=0?
Good luck,
Jim
Quoting "Hallman, Chuck (NIH/NIEHS)" <[EMAIL PROTECTED]>:
> I am new to Java and could use some advice, help, examples .. anything I
> can
> get ..
>
> I am trying to calculate the number of days between two gregorian dates.
>
>
> Example 04/10/1992 - 04/08/1992 = 2 days.
>
> I am using the GregorianCalendar and it works fine as long as the dates
> fall
> within the same year. However, if one of the dates is of a different
> year (
> e.g. - 04/10/1992 - 02/15/1991 ) the calculation does not work
> correctly ..
>
> Does anyone out there have any ideas as to what I am doing wrong?
>
_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org