-1

Ive tried using:

keyboard.nextLine(), 

which gives an error saying that a string cannot be converted to a date, then I tried using:

keyboard.nextDate();

Which gives the error "Cannot find symbol"

 System.out.print("Enter a Release date in the format yyyy-mm-dd");
        e.setReleaseDate(keyboard.next());
        keyboard.nextLine();
  • Have you declared and assigned `keyboard` anywhere? E.g. `final Scanner keyboard = new Scanner(System.in);`? – BeUndead Dec 04 '19 at 11:54
  • What about `e`? – Paplusc Dec 04 '19 at 11:55
  • Your format pattern for the date input (though it is just a hint) is wrong, you are currently asking for year-minutes-day (`"yyyy-mm-dd"`) but you should ask for year-month-day (`"yyyy-MM-dd"`). – deHaar Dec 04 '19 at 11:56

1 Answers1

1

The method setReleaseDate probably expects a date, but the method next returns a String. You need to parse that String with a SimpleDateFormat, for example:

public static void main(String[] args) throws ParseException {
    Scanner scanner = new Scanner(System.in);
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    dateMethod(format.parse(scanner.next()));
}

public static void dateMethod(Date date) {
    System.out.println(date);
}