When you look at the javadoc of the java.util.Date class, most of the methods are deprecated. Why was this done?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, for two related reasons. It was a very poor implementation of the concept of Dates and Times and it was replaced by the
Calendarclass.The
Calendarclass, although an improvement, leaves a lot to be desired as well, so for serious Date/Time work, everyone recommends Joda-Time. Java 8 brings the new java.time.* package, inspired by Joda-Time, defined by JSR-310, and intended to supplant the old Date/Calendar classes.Edit: In response to the specific question of why the implementation is poor, there are many reasons. The JavaDoc sums it up as follows:
In addition to this general deficiency (which covers issues like the lack of a Time Zone component as well as the date formatting which is better handled in
DateFormatand the inability to have a non-Gregorian calendar representation), there are specific issues which really hurt theDateclass, including the fact that year is presented in an offset of 1900 from Common Era year.Calendarhas its own problems, but even as early as JDK 1.1 it was obvious thatjava.util.Datewas not going to cut it. Even thoughCalendaris arguable the worst JDK API, it has taken until version 7 to attempt to address it.