Here you can find the source of diffY(Date endDate, Date startDate)
public static boolean diffY(Date endDate, Date startDate)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String DATE_FORMAT_2 = "yyyy-MM-dd"; public static boolean diffY(Date endDate, Date startDate) { String endTime = toStringFormat_2(endDate); String startTime = toStringFormat_2(startDate); return endTime.compareTo(startTime) >= 1 ? true : false; }/*from w ww. j av a2 s . co m*/ /** * toString for format 2 * * @param date * @return */ public static String toStringFormat_2(Date date) { return dateToString(date, DATE_FORMAT_2); } public static String dateToString(Date date, String format) { if (null == date) { return ""; } SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }