bog
bog

Reputation: 1323

Date is deprecated. Should I use it or not?

Date has many deprecated methods, i.e, getTime, getMounth, etc. Should I avoid using it?

Also, what is the difference between: Date, Calendarand DataPicker?

Upvotes: 0

Views: 144

Answers (1)

jszaday
jszaday

Reputation: 342

Date was deprecated in the JDK v1.1; in other words relatively early during the (ongoing) development of the environment. It was deprecated because of incompatibility with international time standards; while it was intended to reflect coordinated universal time (UTC) it was found that on machines that use the GMT time standard or those that do not reflect a "leap second" (an extra second once every year or two) that the Date class might not be exactly accurate.

For this reason, it is recommended that you use Calendar.get(...) instead of Date's respective methods! Also, Java8 has a UI component, DatePicker, which use's the new LocalDate class (which is a localized replacement for the deprecated Date class).

Upvotes: 3

Related Questions