- public static boolean isInDate(Date date, String strDateBegin,
- String strDateEnd) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String strDate = sdf.format(date);
-
- 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(0, 2));
- int strDateBeginM = Integer.parseInt(strDateBegin.substring(3, 5));
- int strDateBeginS = Integer.parseInt(strDateBegin.substring(6, 8));
-
- int strDateEndH = Integer.parseInt(strDateEnd.substring(0, 2));
- int strDateEndM = Integer.parseInt(strDateEnd.substring(3, 5));
- int strDateEndS = Integer.parseInt(strDateEnd.substring(6, 8));
- if ((strDateH >= strDateBeginH && strDateH <= strDateEndH)) {
-
- if (strDateH > strDateBeginH && strDateH < strDateEndH) {
- return true;
-
- } else if (strDateH == strDateBeginH && strDateM >= strDateBeginM
- && strDateM <= strDateEndM) {
- return true;
-
- } else if (strDateH == strDateBeginH && strDateM == strDateBeginM
- && strDateS >= strDateBeginS && strDateS <= strDateEndS) {
- 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 {
- return false;
- }
- } else {
- return false;
- }
- }
posted @
2019-06-13 10:37
曼殊&沙华
阅读(
1696)
评论()
收藏
举报