r/java • • May 10 '22

Should java.util.Date be deprecated?

https://mail.openjdk.java.net/pipermail/discuss/2022-May/006077.html
221 Upvotes

158 comments sorted by

View all comments

95

u/frzme May 10 '22

I recently had to tell a co-worker not to use SimpleDateFormat in completely new code. If it was marked deprecated I guess this would not have been needed.

27

u/john16384 May 10 '22

I wish LocalDateTime was clearly documented with "did you mean to use Instant?"

50

u/OzoneGrif May 10 '22

Instant and LocalDateTime are very different in behavior. I use LocalDateTime a lot in my applications because I need date and times without timezones (they are resolved dynamically later by another module).

Instant is an absolute point in time with very few meaning by itself. You shouldn't use it to store local date times; that would be a dirty trick.

Programmers should just learn when and how to use both.

1

u/[deleted] May 11 '22