Here you can find the source of compareDate(String s, String e)
Parameter | Description |
---|---|
s | a parameter |
e | a parameter |
public static boolean compareDate(String s, String e)
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class Main { private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static final Lock LOCK = new ReentrantLock(); public static boolean compareDate(String s, String e) { if (parseDate(s) == null || parseDate(e) == null) { return false; }/*ww w . j a va2 s .c om*/ return parseDate(s).getTime() >= parseDate(e).getTime(); } public static Date parseDate(String date) { return parseDate(date, "yyyy-MM-dd"); } public static Date parseDate(String date, String pattern) { LOCK.lock(); try { DateFormat fmt = new SimpleDateFormat(pattern); return fmt.parse(date); } catch (ParseException e) { e.printStackTrace(); return null; } finally { LOCK.unlock(); } } public static String getTime() { return sdfTime.format(new Date()); } }