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

Android Build a Weather App (2015) Working with JSON Formatting a Date

Mark Junge
Mark Junge
1,374 Points

The mReleaseDate member variable is already stored as a Date object. Convert it and return it using the SimpleDateFormat

I wonder how to do this question from "Build a weather app" I have tried everything from the earlier video, just as i also did when i made the application. Im not sure what they want here, hopefully someone can help me.

Movie.java
import java.util.Date;

public class Movie {

    private String mTitle;
    private Date mReleaseDate;

    public String getTitle() {
        return mTitle;
    }

    public void setTitle(String title) {
        mTitle = title;
    }

    public Date getReleaseDate() {
        return mReleaseDate;
    }

    public String getFormattedReleaseDate(){
      SimpleDateFormat simpledateformat= new SimpleDateFormat("yyyy-MM-dd");
      //simpledateformat.setmReleaseDate(mReleaseDate);
      String timestring = SimpleDateFormat(mReleaseDate);

    return timestring;
    }

    public void setReleaseDate(Date date) {
        mReleaseDate = date;

    }
}
Mark Junge
Mark Junge
1,374 Points

My code on the table, might be totally wrong, but just did a lot of different experiments.

So if someone also can explain a bit, it would be fine :-)

2 Answers

Your code is good, except you forgot a method call to "format" so its not actually formatting the date variable.

'''java

  SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd");
  return simpledateformat.format(mReleaseDate);

'''

note that I removed the "timestring" line as it was unnecessary.

Mark Junge
Mark Junge
1,374 Points

Thank you, I appreciate it :-)

Mark Junge
Mark Junge
1,374 Points

Maybe I can ask you another question :-)

I can't get the pictures from drawables in the project to drawables in the Android. When i copy pictures to the Android, it automatically saves them in project and not Android? I have tried to compare but it doesn't compare all the different sizes hdpi, mdpi......

Im not sure what to do :-)?

can i get the complete code