在的话返回true,反之返回false
public static boolean isInDates(String strDate,String strDateBegin,String strDateEnd){ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date myDate = null; Date dateBegin = null; Date dateEnd = null; try { myDate = sd.parse(strDate); dateBegin = sd.parse(strDateBegin); dateEnd = sd.parse(strDateEnd); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } strDate = String.valueOf(myDate); strDateBegin = String.valueOf(dateBegin); strDateEnd = String.valueOf(dateEnd); int strDateH = Integer.parseInt(strDate.substring(11,13)); int strDateM = Integer.parseInt(strDate.substring(14,16)); int strDateS = Integer.parseInt(strDate.substring(17,19)); int strDateBeginH = Integer.parseInt(strDateBegin.substring(11,13)); int strDateBeginM = Integer.parseInt(strDateBegin.substring(14,16)); int strDateBeginS = Integer.parseInt(strDateBegin.substring(17,19)); int strDateEndH = Integer.parseInt(strDateEnd.substring(11,13)); int strDateEndM = Integer.parseInt(strDateEnd.substring(14,16)); int strDateEndS = Integer.parseInt(strDateEnd.substring(17,19)); if((strDateH>=strDateBeginH && strDateH<=strDateEndH)){ if(strDateH>strDateBeginH && strDateH<strDateEndH){ return true; }else if(strDateH==strDateBeginH && strDateM>strDateBeginM && strDateH<strDateEndH){ return true; }else if(strDateH==strDateBeginH && strDateM==strDateBeginM && strDateS>strDateBeginS && strDateH<strDateEndH){ return true; }else if(strDateH==strDateBeginH && strDateM==strDateBeginM && strDateS==strDateBeginS && strDateH<strDateEndH){ return true; }else if(strDateH>strDateBeginH && strDateH==strDateEndH && strDateM<strDateEndM){ return true; }else if(strDateH>strDateBeginH && strDateH==strDateEndH && strDateM==strDateEndM && strDateS<strDateEndS){ return true; }else if(strDateH>strDateBeginH && strDateH==strDateEndH && strDateM==strDateEndM && strDateS==strDateEndS){ return true; }else{ return false; } }else{ return false; } }