Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialshu Chan
2,951 PointsGetting error: incompatible types: Date cannot be converted to String return mCreationDate;
Here is my code, it seems completely the same as the video but I get the message in the title. here is the code
package com.teamtreehouse;
import java.util.Date;
public class Treet{
private String mAuthor;
private String mDescription;
private Date mCreationDate;
public Treet(String author, String description, Date creationDate){
mAuthor = author;
mDescription = description;
mCreationDate = creationDate;
}
public String getAuthor(){
return mAuthor;
}
public String getDescription(){
return mCreationDate;
}
public Date getCreationDate(){
return mCreationDate;
}
}
Anyone know whats wrong?
2 Answers
Mitchell Richmond
5,401 PointsLook at your getDescription() method. You are trying to return mCreationDate rather than returning mDescription.
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 Pointsreturn mDescription in this method. public String getDescription(){ return mCreationDate; }
GhostIn Shell
1,967 PointsGhostIn Shell
1,967 PointsIm having the same issue with corrected code above.
package com.teamtreehouse;
import java.util.Date;
public class Treet { private String mAuthor; private String mDescription; private String mCreationDate;
public Treet(String author, String description, Date creationDate) { mAuthor = author; mDescription = description; mCreationDate = creationDate; }
public String getAuthor() { return mAuthor; }
public String getDescription() { return mDescription; }
public Date getCreationDate() { return mCreationDate; }
}