Forum Stats

  • 3,827,140 Users
  • 2,260,744 Discussions
  • 7,897,181 Comments

Discussions

Why not Deprecate java.util.Date and java.util.Calendar

atehrani-JavaNet
atehrani-JavaNet Member Posts: 2
edited Jun 5, 2014 1:43PM in Java 8 Questions

With the introduction of java.time, why did you not flag java.util.Date and java.util.Calendar. These classes have been a bane to every Java developer and should never be used again with the introduction of Java 1.8.

arofergbishop

Answers

  • jwenting
    jwenting Member Posts: 4,864 Gold Badge

    because they actually work, unlike the new API which is a total kludge.

    And of course because there are like a billion 3rd party libraries (as well as many from Sun/Oracle themselves) which are reliant on them.

    arofer
  • Adding the @Deprecated annotation would only just provide a warning about an old API and recommendation to the developer(s) to no longer use it. Doing so would not break any existing library out there; in fact quite a number of constructors and methods on the Date class have already been flagged deprecated.

    The new java.time package is far superior to Date/Calendar.

  • jwenting
    jwenting Member Posts: 4,864 Gold Badge

    that's your opinion. It's not at all transparent, unintuitive to the extreme, and from personal experience (I was involved in the JSR group for a while when they first started) decided more on pseudo-religious and political ideology than on what's actually useful.

    Hence the total lack of capabilities to easily convert to and from the traditional API for example.

  • gbishop
    gbishop Member Posts: 10

    Instant (Java Platform SE 8 ) Seems pretty straightforward to me to get the number of seconds since Jan 1 1970 in Date/Calendar and convert it to an Instant.  What's the problem?