Java Date Compare compareDate(String date1, String date2)

Here you can find the source of compareDate(String date1, String date2)

Description

compare Date

License

Open Source License

Declaration

public static boolean compareDate(String date1, String date2) 

Method Source Code


//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

    public static boolean compareDate(String date1, String date2) {
        try {//  w  ww .  j a va  2s .  c  o m
            Date d1 = formatter.parse(date1);
            Date d2 = formatter.parse(date2);
            return !d1.after(d2);
        } catch (ParseException e) {
            e.printStackTrace();
            return false;
        }
    }
}

Related

  1. compareDate(String d1, String d2)
  2. compareDate(String date)
  3. compareDate(String date0, String date1)
  4. compareDate(String date1, File file)
  5. compareDate(String DATE1, String DATE2)
  6. compareDate(String s, String e)
  7. compareDate(String s, String e)
  8. compareDate(String sDate, String eDate, String formatStr)
  9. compareDate(String sFirstDate, String sSecondDate)