Java Date Compare isBeforeDate(String sCompareDate)

Here you can find the source of isBeforeDate(String sCompareDate)

Description

is Before Date

License

Apache License

Declaration

public static boolean isBeforeDate(String sCompareDate) 

Method Source Code


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

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static boolean isBeforeDate(String sCompareDate) {
        SimpleDateFormat clsFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {/*from  w  ww  .ja  v  a  2  s .c  o  m*/
            Date compareDate = clsFormat.parse(sCompareDate);
            // Date compareDate = clsFormat.parse("2006-02-11");
            Date currentDate = clsFormat.parse(clsFormat.format(new Date()));
            // Date currentDate =clsFormat.parse("2006-02-06");
            if (currentDate.before(compareDate)) {
                return true;
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return false;
    }
}

Related

  1. getCompareDate(String strDate1, String strDate2, String pFormat)
  2. getCompareDate(String strDate1, String strDate2, String pFormat)
  3. getCompareDateNum(String sDateValue1, String sDateValue2)
  4. getCompareResult(String date1, String date2)
  5. isAfterOrEqual(Date date, Date toCompare)
  6. isInDate(Date date, Date compareDate)
  7. max(Collection datumok)
  8. max(Date a, Date b)
  9. max(final Date a, final Date b)