Java Date Compare compareDate(String date)

Here you can find the source of compareDate(String date)

Description

compare Date

License

Open Source License

Declaration

public static boolean compareDate(String date) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static boolean compareDate(String date) {
        Date d = new Date();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String dateNowStr = df.format(d);

        try {//from ww w.ja va  2  s. c o  m
            Date dt1 = df.parse(date);
            Date dt2 = df.parse(dateNowStr);

            if (dt1.getTime() > dt2.getTime()) {
                return true;
            } else {
                return false;
            }
        } catch (Exception exception) {
            exception.printStackTrace();
            return false;
        }
    }
}

Related

  1. compareDate(Date sourceDate, Date targetDate)
  2. compareDate(Date start, Date end)
  3. compareDate(String begingDate, String endDate, String format)
  4. compareDate(String d1, String d2)
  5. compareDate(String d1, String d2)
  6. compareDate(String date0, String date1)
  7. compareDate(String date1, File file)
  8. compareDate(String date1, String date2)
  9. compareDate(String DATE1, String DATE2)