Java Date Compare compareDate(String s, String e)

Here you can find the source of compareDate(String s, String e)

Description

compare Date

License

Open Source License

Declaration

public static boolean compareDate(String s, String e) 

Method Source Code


//package com.java2s;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static boolean compareDate(String s, String e) {
        if (fomatDate(s) == null || fomatDate(e) == null) {
            return false;
        }//from  www .j  a v a 2s.c  o  m
        return fomatDate(s).getTime() >= fomatDate(e).getTime();
    }

    public static Date fomatDate(String date) {
        DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
        try {
            return fmt.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static String getTime() {
        return sdfTime.format(new Date());
    }
}

Related

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