Java Year diffYears(Date day1, Date day2)

Here you can find the source of diffYears(Date day1, Date day2)

Description

diff Years

License

Open Source License

Declaration

public static int diffYears(Date day1, Date day2) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {

    public static int diffYears(Date day1, Date day2) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(day1);//from ww  w. j  a v a 2  s . co m
        int startYear = cal.getWeekYear();
        cal.clear();
        cal.setTime(day2);
        int endYear = cal.getWeekYear();
        int diffyears = endYear - startYear;
        return diffyears;
    }
}

Related

  1. createCalendarAtBeginningOfYear(int year)
  2. currentYear()
  3. daysInYear(int year)
  4. differenceInYears(final Calendar a, final Calendar b)
  5. IsInLeapYear(Date date1)
  6. isLeapYear(int year)
  7. nextYears(int diff)
  8. sameYear(Date date1, Date date2)