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 trialPeter Danglay
861 PointsI do not understand the new Date(); part of this video
Hello can someone please give me an explanation of this new Dare(); part of the video I do not understand
2 Answers
Allan Clark
10,810 PointsNew date creates a new instance of the date class. We need to use the long parameter because the older constructor should no longer be used. This parameter represents the amount of time that has passed since Jan 1 1970 iirc.
Hope this helps. If you need more clarity let me know specifically what part is unclear.
Happy coding!!
Peter Danglay
861 PointsI don't understand the part when new date creates a new instance of the date class
Peter Danglay
861 Pointsif it creates an instance how come I can't use that instance
Allan Clark
10,810 PointsThe new instance of Date is sent in as a parameter to the constructor of the Treet object. It is then stored in a private variable, which means only the object itself can access the variable. You can access the value of that Date object with the getter method. By design there is no way to change that date after the Treet object's initial construction. If you think ab it this makes sense bc of what that date object represents, and that is the date the Treet was created. It wouldnt make sense to change that date after the Treet has been created.