Java Date Format Check checkDate(String begingDate, String endDate)

Here you can find the source of checkDate(String begingDate, String endDate)

Description

check Date

License

Open Source License

Declaration

public static boolean checkDate(String begingDate, String endDate) 

Method Source Code


//package com.java2s;

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static boolean checkDate(String begingDate, String endDate) {
        boolean boo = true;
        Date begin = null;// www.ja va  2 s  . c om
        Date end = null;
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        if (null == begingDate || "".equals(begingDate)) {
            boo = false;
            return boo;
        }
        if (null == endDate || "".equals(endDate)) {
            boo = false;
            return boo;
        }
        try {
            begin = df.parse(begingDate);
            end = df.parse(endDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        if (begin.compareTo(end) >= 0) {
            boo = false;
        }
        return boo;
    }

    public static String parse(Date d) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
        String dateStr = sdf.format(d);
        return dateStr;
    }
}

Related

  1. checkDate(Date date)
  2. checkDate(String deadline)
  3. checkDateBetween(String time)
  4. checkDateByMask(String sDateValue, String sDateFormat)
  5. checkDateFormat()