DatetimeTools.java 479 Bytes
package com.xkl.tools;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by zhaoyue on 2017/3/11.
 */
public class DatetimeTools {
    public static int getAge(Date start, Date end) {
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        c1.setTime(start);
        c2.setTime(end);
        int year1 = c1.get(Calendar.YEAR);
        int year2 = c2.get(Calendar.YEAR);
        return Math.abs(year1 - year2);
    }
}