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 trialDalton Coble
6,489 PointsI could use a little help please.
I am not sure how to do what it is asking. here is the question:
I modified our Movie class to have a full date for the release date instead of just the year. We want to display it in yyyy-MM-dd format, though. Add a new method to format it called getFormattedReleaseDate(), but don't add any code yet. Make it return a String and just return an empty String to start.
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 void setReleaseDate(Date date) {
mReleaseDate = date;
}
}
4 Answers
Ken Alger
Treehouse TeacherJody;
For Task 1 you just need to write the basic function structure, that returns a string, and to start with have it return an empty string.
Something along the lines of:
public String getFormattedReleaseDate () {
return "";
}
That is the start of the date formatting challenge, Tasks 2 & 3 build upon this function layout.
Post back if you are still stuck.
Ken
LeJacque Gillespie
3,990 PointsPART 2 OF THE CODE
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Adlight Sibanda
5,701 Pointsnoted could you please also assist with challenge 3 of 3, The mReleaseDate member variable is already stored as a Date object. Convert it and return it using the SimpleDateFormat variable.
Exavier Mugasa
4,088 PointsThis one worked for me: import java.util.Date;
public class Movie {
private String mTitle;
private Date mReleaseDate;
public String getTitle() {
return mTitle;
}
public String getFormattedReleaseDate() {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
return "";
LeJacque Gillespie
3,990 Pointsthis is what i came up with and it passed
import java.util.Date;
public class Movie {
private String mTitle;
private Date mReleaseDate;
public String getFormattedReleaseDate() {
return"";
}
public String getTitle() {
return mTitle;
}
public void setTitle(String title) {
mTitle = title;
}
public Date getReleaseDate() {
return mReleaseDate;
}
public void setReleaseDate(Date date) {
mReleaseDate = date;
}
}
Andre Colares
5,437 PointsAdlight Sibanda, here is the code for part 3:
public String getFormattedReleaseDate() {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = formatter.format(mReleaseDate);
return formattedDate;
}
Dalton Coble
6,489 PointsDalton Coble
6,489 Pointsok thanks so muck that worked.
MUZ140566 Kundai Katambetambe@gmail.com
4,845 PointsMUZ140566 Kundai Katambetambe@gmail.com
4,845 Pointswhere do those lines fit on the code i am lost
LeJacque Gillespie
3,990 PointsLeJacque Gillespie
3,990 Pointstry making the new code the first one, take a look at mine.