There is quite a working code that displays the date from what the user entered.
String dateString = scan.nextLine(); String expectedPattern = "dd/MM/yyyy"; SimpleDateFormat formatter = new SimpleDateFormat(expectedPattern); try { Date date = formatter.parse(dateString); System.out.println(dateString); System.out.println(date); } catch (ParseException e) { e.printStackTrace(); } But I can't understand why when I write this code inside the case
int choice = scan.nextInt(); switch (choice) { case 1: Then it stops working and gives an error java.text.ParseException: Unparseable date: "" . What I need is that when a certain case is selected, the user can enter a date, which is then written to the array. Maybe this can be done in some other way?