I am trying to write something that allows someone to check an audio book out for class, and it should set a due date for 14 days later. My class has a toString() method that should print out the due date, but consistently prints out that it is due 3/5 no matter what.
public String toString() // Prints specs of a Book object
{
String str = "
The specs of this audiobook are: ";
str += "
Title: " + title;
str += "
Narrator: " + narrator;
str += "
Year: " + year;
str += "
Due Date: " + (getReturnDate().MONTH + 1) + "/" + getReturnDate().DATE;
return str;
}
public Calendar getReturnDate() // Makes return date 14 days after today
{
Calendar duedate = Calendar.getInstance();
duedate.add(Calendar.DAY_OF_YEAR, 14);
return duedate;
}
See Question&Answers more detail:os