Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is java.util.Date's setTime() method not deprecated?

All the other mutators got deprecated back in JDK 1.1, so why was setTime() left as is? Surely java.util.Calendar - the correct way to manipulate dates - can create new instances of java.util.Date as needed using the java.util.Date(long) constructor?

like image 991
Dan Haywood Avatar asked Dec 14 '22 02:12

Dan Haywood


1 Answers

The bits of Date that were deprecated were those bits that related to calendars (i.e. day, month, year, etc). You'll note that the accessor methods for calendar fields are also deprecated, not just the mutators.

The representation as a milliseconds value, however, is still the way Date works, and is unrelated to the calendar representation, so it stayed as undeprecated.

like image 115
skaffman Avatar answered Dec 26 '22 12:12

skaffman