Here you can find the source of getYearBetweenTwoDate(Date fdate, Date tdate)
Parameter | Description |
---|---|
fdate | begin date |
tdate | end date |
public static int getYearBetweenTwoDate(Date fdate, Date tdate)
//package com.java2s; /*//from w ww .jav a 2s .c o m * File: $RCSfile$ * * Copyright (c) 2005 Wincor Nixdorf International GmbH, * Heinz-Nixdorf-Ring 1, 33106 Paderborn, Germany * All Rights Reserved. * * This software is the confidential and proprietary information * of Wincor Nixdorf ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered * into with Wincor Nixdorf. */ import java.util.Date; import java.util.Calendar; public class Main { /** * Return offset years between specified begin date and end date * * @param fdate begin date * @param tdate end date * @return offset number */ public static int getYearBetweenTwoDate(Date fdate, Date tdate) { Calendar f = Calendar.getInstance(); f.setTime(fdate); Calendar t = Calendar.getInstance(); t.setTime(tdate); return t.get(Calendar.YEAR) - f.get(Calendar.YEAR); } }