Java Date Value Check isDateBefore(String date1, String date2)

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

Description

is Date Before

License

Apache License

Declaration

public static boolean isDateBefore(String date1, String date2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.DateFormat;
import java.text.ParseException;

import java.util.Date;

public class Main {

    public static boolean isDateBefore(String date1, String date2) {
        try {/*from  w  w w. ja v a2 s .c o  m*/
            DateFormat df = DateFormat.getDateTimeInstance();
            return df.parse(date1).before(df.parse(date2));
        } catch (ParseException e) {
            return false;
        }
    }

    public static boolean isDateBefore(String date2) {
        if (date2 == null) {
            return false;
        }
        try {
            Date date1 = new Date();
            DateFormat df = DateFormat.getDateTimeInstance();
            return date1.before(df.parse(date2));
        } catch (ParseException e) {
            return false;
        }
    }
}

Related

  1. isDate(String strDate, String pattern)
  2. isDate(String text, String pattern)
  3. isDate(String val, SimpleDateFormat formatter)
  4. isDate(String value, Locale locale)
  5. isDateBefore(String date1)
  6. isDateBefore(String date1, String date2)
  7. isDateFormat(String dateString)
  8. isDateFormat(String str, String format)
  9. isDateFormatString(String s, String dateFormat, Locale locale)