private void insertIntoCalendar() { // Capture event title and event date and time from user input ArrayList eventInfo = uniquelyIdentifyEvent(); String eventTitle = (String) eventInfo.get(0); LocalDateTime eventDateTime = (LocalDateTime) eventInfo.get(1); // Capture event notes from user input String eventNotes = ""; while (!eventNotes.matches("[\\w\\p{Punct} ]+")) { System.out.print( " Enter event notes (can contain letters, digits, punctuation, and spaces): "); eventNotes = scanner.nextLine(); if (!eventNotes.matches("[\\w\\p{Punct} ]+")) { System.out.println(" Incorrect format for event notes. Try again."); } } // Capture the event recurring type from user input String repeatType = ""; while (!repeatType.matches("\\bnone|daily|weekly|monthly|yearly\\b")) { System.out.print( " Enter how often the event is recurring: (one of [none, daily, weekly, monthly, yearly] ): "); repeatType = scanner.nextLine(); } // Schedule new event on calendar from obtained user input try { // Try to schedule an event with the user-set parameters if (repeatType.matches("none$")) { calendar.addEvent(eventTitle, eventDateTime, eventNotes); } else { // schedule a recurring event calendar.addEvent(eventTitle, eventDateTime, eventNotes, repeatType); } } catch (InputMismatchException e) { System.out.println( " Error while creating event. Event date must be within one year of today's date."); } }