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

Why Epoch Converter???

Is there a way of inputting the correct datetime format like so(21-01-2016 2.15pm) without converting it to milliseconds?

isaac schwartzman
isaac schwartzman
963 Points

I don't believe so because the date class was designed to be precise down to the millisecond.

2 Answers

John Anselmo
PLUS
John Anselmo
Courses Plus Student 2,281 Points

Well... there is... As Craig said there are several methods that you CAN use from java.util.Date, however they are deprecated... meaning you CAN use them if you want to, but they can be removed at any time. Meaning one day your program will work, another day it might not.

Sebastian Röder
Sebastian Röder
13,878 Points

Since Java 8 there is a new Date and Time API. A local date (that is a date without any time zone information) can be created like this:

import java.time.LocalDate;

LocalDate christmas = LocalDate.of(2017, 12, 24);

// shortcut for todays date
LocalDate creationDate = LocalDate.now();

Since this API is pretty clean an easy to understand I am not sure why the confusing concept of the epoch converter was introduced instead.