Search code examples
javastringmodel-view-controllercrudlocaldate

how do I convert LocalDate to String form so it prints out the date inputed


   public void displayDVD(DVD dvd) {
       if (dvd != null) {
           io.print(dvd.getTitle());
           io.print(dvd.getReleaseDate());
           io.print(dvd.getMpaaRating());
           io.print(dvd.getDirectorsName());
           io.print(dvd.getStudio());
           io.print(dvd.getUserRating());

I need to display the getReleaseDate, but it's telling me I can't because its a LocalDate and can't be a string. Probably a rookie look, but really can't find a way around it. Thanks in advance!


Solution

  • Try this.

    public void displayDVD(DVD dvd) {
        if (dvd != null) {
            io.print(dvd.getTitle());
            io.print(dvd.getReleaseDate().toString());
            io.print(dvd.getMpaaRating());
            io.print(dvd.getDirectorsName());
            io.print(dvd.getStudio());
            io.print(dvd.getUserRating());