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 trial

Java Java Data Structures Getting There Class Review

shu Chan
shu Chan
2,951 Points

Getting 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?

GhostIn Shell
GhostIn Shell
1,967 Points

Im 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; }

}

2 Answers

Mitchell Richmond
Mitchell Richmond
5,401 Points

Look at your getDescription() method. You are trying to return mCreationDate rather than returning mDescription.