Esempio n. 1
0
  private boolean isValidTime(String tTime) {
    String[] sTime = tTime.split(":");

    if (sTime.length != 3) {
      return false;
    }
    if (!Toolket.isNumeric(sTime[0])
        || !Toolket.isNumeric(sTime[1])
        || !Toolket.isNumeric(sTime[2])) {
      return false;
    }

    int t = Integer.parseInt(sTime[0]);
    if (t < 0 || t > 24) return false;

    t = Integer.parseInt(sTime[1]);
    if (t < 0 || t > 59) return false;

    t = Integer.parseInt(sTime[2]);
    if (t < 0 || t > 59) return false;

    return true;
  }
Esempio n. 2
0
  private ActionMessages validateInput(DynaActionForm form) {
    ActionMessages msgs = new ActionMessages();

    String level = form.getString("level");
    String levelSel = form.getString("levelSel");
    String depart = form.getString("depart");
    String departSel = form.getString("departSel");
    String beginDate = form.getString("beginDate");
    String beginTime = form.getString("beginTime");
    String endDate = form.getString("endDate");
    String endTime = form.getString("endTime");
    log.debug("depart:" + depart + ", departSel:" + departSel);
    if (!level.equals(levelSel)) {
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.ScoreUploadLevelErr"));
      return msgs;
    }

    if (!depart.equals(departSel)) {
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.DepartmentInputErr"));
      return msgs;
    }

    String[] tDate = beginDate.split("/");
    if (tDate.length != 3) {
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidDateInput"));
      return msgs;
    } else {
      if (!Toolket.isNumeric(tDate[0])
          || !Toolket.isNumeric(tDate[1])
          || !Toolket.isNumeric(tDate[2])) {
        msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidDateInput"));
        return msgs;
      }

      tDate[0] = "" + Integer.parseInt(tDate[0]) + 1911;
    }

    if (!isValidDate(tDate[0], tDate[1], tDate[2])) {
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidDateInput"));
      return msgs;
    }

    tDate = endDate.split("/");
    if (tDate.length != 3) {
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidDateInput"));
      return msgs;
    } else {
      if (!Toolket.isNumeric(tDate[0])
          || !Toolket.isNumeric(tDate[1])
          || !Toolket.isNumeric(tDate[2])) {
        msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidDateInput"));
        return msgs;
      }

      tDate[0] = "" + Integer.parseInt(tDate[0]) + 1911;
    }

    if (!isValidDate(tDate[0], tDate[1], tDate[2])) {
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidDateInput"));
      return msgs;
    }

    if (!isValidTime(beginTime)) {
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidTimeInput"));
      return msgs;
    }

    if (!isValidTime(endTime)) {
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidTimeInput"));
      return msgs;
    }

    return msgs;
  }