开始时间组:[10:11:09, 10:12:09, 10:13:09]线束时间组:[11:11:09, 11:12:09, 11:13:09]
10:11:09 -- 11:11:09  这就是一时间段。
开始时间一一对应结束时间,要验证其中一时间不能在其它时间段中。
求解(JAVA)

解决方案 »

  1.   

    Date dateBegin;//起始时间
    Date dateEnd;  //结束时间
    Date currentDate; //待比较时间String result = (currentDate.before(dateEnd) && (currentDate.after(dateBegin)))?"服务时间段内" : "服务时间段外";大概是这样吧.
      

  2.   

    就比如原数组为a,b,将a,b数组合并成一新数组c,如果,(c0,c1),(c2*i,c(2*i+1))的元素不同时属于同一个数组a或者b,并且,如果c0在a中的下标为k是,c1在b中的下标也为k,则满足要求的!
      

  3.   

    public static boolean dateCompare(Date t1,Date t2) {
      boolean dateComPareFlag = true;
      if (d2.compareTo(d1) != 1) {
       dateComPareFlag = false; // 
      }
      return dateComPareFlag;
     }
      

  4.   

    我要的是算法,而不是 API (before, compareTo, after)
      

  5.   

    CSDN没牛人?还是牛人喜欢潜水?
      

  6.   

    大概思路:(伪代码)
    方法参数:
    Date[] beginDates ;//原始开始时间数组
    Date[] endDates;//原始结束时间数组,大小与上一个数组相同
    Date targetBegin,targetEnd//需要往里面插入的目标(起始时间<结束时间);
    方法主题,返回值false表示不可以插入:日期比较大小请自己修改喔
    for(int i =0;i<beginDates.length;i++){
     if(targetBegin>=beginDates[i]&&targetBegin<=endDate[i]){//起始时间属于另外一个时间组
        return false;
    }else if(targetEnd>=beginDates[i]&&targetEnd<=endDates[i]){//结束时间属于另外一个时间组
        return false;}
    }
    return true;
      

  7.   

    漏掉一种情况:
    if(targetEnd<beginDates[i]&&targetEnd>endDates[i]) return false;
      

  8.   

    又打错=。=
    if(targetBegin<beginDates[i]&&targetEnd>endDates[i]) return false;
      

  9.   


    恩,这个存储的数据是模拟的。
    String[] startDate=new String(){"08:00:00", "10:00:00", "12:00:00"};String[] endDate=new String(){"09:00:00", "11:00:00", "13:00:00"};startDate[0]对应 endDate[0],这为一时间段,以此类推。
      

  10.   


    要匹配整个数组,targetBegin,targetEnd 这个只匹配一次
      

  11.   


    是服务端验证,而且用户增加时间段是没有限制的。
    如果删掉的话,会降低用户体验,用户会很郁闷,填的东西怎么会提示没有了?
    web项目就是这样子的。