Hi, how can i make method calculates how many years have passed since the publication of the book. I don't know how to get today year so i can take it out from bookDateOfMade
public class Book { private String bookName; private String bookAuthor; private LiteratureGenre bookGenre; private Locale bookLanguage; private LocalDate bookDateOfMade; public Book(String bookName, String bookAuthor, LiteratureGenre bookGenre, Locale bookLanguage, LocalDate bookDateOfMade) { this.bookName = bookName; this.bookAuthor = bookAuthor; this.bookGenre = bookGenre; this.bookLanguage = bookLanguage; this.bookDateOfMade = bookDateOfMade; } public String getBookName() { return bookName; } public void setBookName(String bookName) { this.bookName = bookName; } public String getBookAuthor() { return bookAuthor; } public void setBookAuthor(String bookAuthor) { this.bookAuthor = bookAuthor; } public LiteratureGenre getBookGenre() { return bookGenre; } public void setBookGenre(LiteratureGenre bookGenre) { this.bookGenre = bookGenre; } public Locale getBookLanguage() { return bookLanguage; } public void setBookLanguage(Locale bookLanguage) { this.bookLanguage = bookLanguage; } public LocalDate getBookDateOfMade() { return bookDateOfMade; } public void setBookDateOfMade(LocalDate bookDateOfMade) { this.bookDateOfMade = bookDateOfMade; } @Override public String toString() { return "The Book " + bookName + " written by " + bookAuthor + " with genre " + bookGenre + "the copy language " + bookLanguage + " was made on " + bookDateOfMade; } public String toShortString() { return "The Book " + bookName + " written by " + bookAuthor ; } public static getAge() { } }
considered different codes
myCal.get(Calendar.YEAR);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)