P.Hill wrote:
> Seamus wrote:
> > long elapsed = d2.getTime() - d1.getTime();
> > // elapsed is in milliseconds so we have to convert to year
> > int years = elapsed * 1000 * 60 * 60 * 24 * 365;
>
> // leap years make it more complex TEISTTR
>
> Oh and since we don't use a calendar with leaps (nor funny days with 23
> and 24 hours) then it really isn't important. Oh wait we do, so your
> solution is pretty poor suggestion, particularly for those real world
> calculations like right about the same time last year to right about the
> same time this year.
>
> Suggestion to OP, use the Calendar object and convert properly to
> either calendar year and if you want more than (any day in ) 2006
> minus (any day in) 2005 is 1, I'd suggest working with day of year
> or month of year and day of month to work out "delta years" instead of
> "calendar years". All the fields I mentioned are available from
> java.util.Calendar.
>
> -Paul
Yes, and I mentioned that - smartass.
|