Here you can find the source of isConfilct(String begintimeOne, String endtimeOne, String begintimeTwo, String endtimeTwo)
public static boolean isConfilct(String begintimeOne, String endtimeOne, String begintimeTwo, String endtimeTwo)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private final static String DATE_FORMAT = "yyyy-MM-dd"; private static final Object[] Date = null; public static boolean isConfilct(String begintimeOne, String endtimeOne, String begintimeTwo, String endtimeTwo) {/*from w w w . jav a 2s .c om*/ Date beginOne = getFormatDate(begintimeOne); Date endOne = getFormatDate(endtimeOne); Date beginTwo = getFormatDate(begintimeTwo); Date endTwo = getFormatDate(endtimeTwo); if ((beginOne.compareTo(beginTwo) <= 0 && endOne.compareTo(beginTwo) >= 0) || (beginOne.compareTo(endTwo) <= 0 && endOne.compareTo(endTwo) >= 0) || (beginTwo.compareTo(beginOne) <= 0 && endTwo.compareTo(beginOne) >= 0) || (beginTwo.compareTo(endOne) <= 0 && endTwo.compareTo(endOne) >= 0)) { return true; } return false; } public static String getFormatDate(java.util.Date currDate) { return getFormatDate(currDate, DATE_FORMAT); } public static Date getFormatDate(String currDate) { return getFormatDate(currDate, DATE_FORMAT); } public static String getFormatDate(java.util.Date currDate, String format) { if (currDate == null) { return ""; } SimpleDateFormat dtFormatdB = null; try { dtFormatdB = new SimpleDateFormat(format); return dtFormatdB.format(currDate); } catch (Exception e) { dtFormatdB = new SimpleDateFormat(DATE_FORMAT); try { return dtFormatdB.format(currDate); } catch (Exception ex) { } } return null; } public static Date getFormatDate(String currDate, String format) { if (currDate == null) { return null; } SimpleDateFormat dtFormatdB = null; try { dtFormatdB = new SimpleDateFormat(format); return dtFormatdB.parse(currDate); } catch (Exception e) { dtFormatdB = new SimpleDateFormat(DATE_FORMAT); try { return dtFormatdB.parse(currDate); } catch (Exception ex) { } } return null; } }