コード例 #1
0
  @RequestMapping(value = "/move", method = RequestMethod.POST)
  @ResponseBody
  public String moveCalendar(
      @RequestParam("id") Long id,
      @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = dataFormat)
          Date start,
      @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = dataFormat)
          Date end) {
    Calendar calendar = calendarService.findOne(id);

    if (end == null) {
      end = start;
    }

    calendar.setStartDate(start);
    calendar.setLength((int) Math.ceil(1.0 * (end.getTime() - start.getTime()) / oneDayMillis));
    if (DateUtils.isSameDay(start, end)) {
      calendar.setLength(1);
    }
    if (!"00:00:00".equals(DateFormatUtils.format(start, "HH:mm:ss"))) {
      calendar.setStartTime(start);
    }
    if (!"00:00:00".equals(DateFormatUtils.format(end, "HH:mm:ss"))) {
      calendar.setEndTime(end);
    }
    calendarService.copyAndRemove(calendar);

    return "ok";
  }
コード例 #2
0
  @RequestMapping(value = "/new", method = RequestMethod.GET)
  public String showNewForm(
      @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = dataFormat)
          Date start,
      @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = dataFormat) Date end,
      Model model) {

    setColorList(model);

    Calendar calendar = new Calendar();
    calendar.setLength(1);
    if (start != null) {
      calendar.setStartDate(start);
      calendar.setLength((int) Math.ceil(1.0 * (end.getTime() - start.getTime()) / oneDayMillis));
      if (DateUtils.isSameDay(start, end)) {
        calendar.setLength(1);
      }
      if (!"00:00:00".equals(DateFormatUtils.format(start, "HH:mm:ss"))) {
        calendar.setStartTime(start);
      }
      if (!"00:00:00".equals(DateFormatUtils.format(end, "HH:mm:ss"))) {
        calendar.setEndTime(end);
      }
    }
    model.addAttribute("model", calendar);
    return viewName("newForm");
  }