Here you can find the source of compareDates(final String format, final Date date1, final Date date2)
public static int compareDates(final String format, final Date date1, final Date date2)
//package com.java2s; /**//w w w. j a v a2s .c om * Copyright ? 2002 Instituto Superior T?cnico * * This file is part of FenixEdu Academic. * * FenixEdu Academic is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * FenixEdu Academic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with FenixEdu Academic. If not, see <http://www.gnu.org/licenses/>. */ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static int compareDates(final String format, final Date date1, final Date date2) { final DateFormat dateFormat = new SimpleDateFormat(format); final String date1String = dateFormat.format(date1); final String date2String = dateFormat.format(date2); return date1String.compareTo(date2String); } public static String format(final String format, final Date date) { return new SimpleDateFormat(format).format(date); } }