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 - Retired Getting There Class Review

tayo mogaji
tayo mogaji
3,312 Points

String cannot be converted to Date

I keep getting this same error...

Example.java:8: error: incompatible types: String cannot be converted to Date "craigdennis",

Could someone please point out where I've gone wrong?

com/example/BlogPost.java
import java.util.Date;
import com.teamtreehouse.Treet;

public class Example {

    public static void main (String[] args) {
    Treet treet = new Treet(
        "craigdennis",
     "Want to be famous? Simply tweet about Java and use "+
     "the hashtag #treet. I'll use your tweet in a new " +
     "@treehouse course about data structures.",
     new Date(1421849732000L)
    );
        System.out.printf("this is a new Treet: %s %n", treet);
    }
}   

1 Answer

David Renger
David Renger
934 Points

Hi Tayo,

You probably made a mistake in your getters in your Treet.java file. Perhaps you wrote something like:

public Date getAuthor() { return mAuthor;
}

It should be String, not Date.