private String[] setStandardTime(String requestUid, String time, User user) {

    final ZonedDateTime proposedDateTime;
    final String dateTimePrompt = getMessage(thisSection, "confirm", "time." + time, user);

    ZonedDateTime zonedNow = Instant.now().atZone(DateTimeUtil.getSAST());

    switch (time) {
      case "instant":
        proposedDateTime = zonedNow.plusMinutes(7L).truncatedTo(ChronoUnit.SECONDS);
        break;
      case "hour":
        proposedDateTime = zonedNow.plusHours(1L);
        break;
      case "day":
        proposedDateTime = zonedNow.plusDays(1L);
        break;
      case "week":
        proposedDateTime = zonedNow.plusWeeks(1L);
        break;
      default:
        // this should never be called, but need it else Java throws error -- defaulting to instant
        proposedDateTime = zonedNow.plusMinutes(7L);
        break;
    }

    eventRequestBroker.updateEventDateTime(
        user.getUid(), requestUid, proposedDateTime.toLocalDateTime());
    EventRequest voteRequest = eventRequestBroker.load(requestUid);
    return new String[] {voteRequest.getName(), dateTimePrompt};
  }
 private String[] setCustomTime(String requestUid, String userInput, User user) {
   LocalDateTime parsedTime = eventUtil.parseDateTime(userInput);
   userLogger.recordUserInputtedDateTime(
       user.getUid(), userInput, "vote-custom", UserInterfaceType.USSD);
   eventRequestBroker.updateEventDateTime(user.getUid(), requestUid, parsedTime);
   final String dateTimePrompt = "at " + parsedTime.format(dateTimeFormat);
   return new String[] {eventRequestBroker.load(requestUid).getName(), dateTimePrompt};
 }
  /*
  Final menu asks for confirmation, then sends out
   */
  @RequestMapping(value = path + "confirm")
  @ResponseBody
  public Request voteConfirm(
      @RequestParam(value = phoneNumber) String inputNumber,
      @RequestParam(value = entityUidParam) String requestUid,
      @RequestParam(value = userInputParam) String userInput,
      @RequestParam(value = "time", required = false) String time,
      @RequestParam(value = "field", required = false) String field,
      @RequestParam(value = interruptedFlag, required = false) boolean interrupted)
      throws URISyntaxException {

    User user = userManager.findByInputNumber(inputNumber, saveVoteMenu("confirm", requestUid));

    String[] promptFields;

    if (!interrupted) {
      switch (field) {
        case "standard":
          promptFields = setStandardTime(requestUid, time, user);
          break;
        case "custom":
          promptFields = setCustomTime(requestUid, userInput, user);
          break;
        case "issue":
          promptFields = adjustSubject(requestUid, userInput, user);
          break;
        default:
          promptFields = new String[] {"Error!", "Error occurred!"};
          break;
      }
    } else {
      EventRequest vote = eventRequestBroker.load(requestUid);
      promptFields =
          new String[] {
            vote.getName(), "at " + vote.getEventDateTimeAtSAST().format(dateTimeFormat)
          };
    }

    USSDMenu menu = new USSDMenu(getMessage(thisSection, "confirm", promptKey, promptFields, user));
    menu.addMenuOption(
        voteMenus + "send" + entityUidUrlSuffix + requestUid,
        getMessage(thisSection, "confirm", optionsKey + "yes", user));
    menu.addMenuOption(
        backVoteUrl("issue", requestUid),
        getMessage(thisSection, "confirm", optionsKey + "topic", user));
    menu.addMenuOption(
        backVoteUrl("time", requestUid),
        getMessage(thisSection, "confirm", optionsKey + "time", user));

    return menuBuilder(menu);
  }
 private String[] adjustSubject(String requestUid, String userInput, User user) {
   String dateTime;
   eventRequestBroker.updateName(user.getUid(), requestUid, userInput);
   EventRequest vote = eventRequestBroker.load(requestUid);
   if (vote.getEventStartDateTime().isBefore(Instant.now().plus(7, ChronoUnit.MINUTES))) {
     // user is manipulating an "instant" vote so need to reset the counter, else may expire before
     // send
     eventRequestBroker.updateEventDateTime(
         user.getUid(), requestUid, LocalDateTime.now().plusMinutes(7L));
     dateTime = getMessage(thisSection, "confirm", "time.instant", user);
   } else {
     // need a quick way to do "at" in i18n
     dateTime = "at " + vote.getEventDateTimeAtSAST().format(dateTimeFormat);
   }
   return new String[] {userInput, dateTime};
 }