Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {

    public static int getDiffOfYears(Date starDate, Date endDate) {
        Calendar star = Calendar.getInstance();
        star.setTime(starDate);
        Calendar end = Calendar.getInstance();
        end.setTime(endDate);
        int diffYear = star.get(Calendar.YEAR) - end.get(Calendar.YEAR);
        return Math.abs(diffYear);
    }
}