What is the Best Practice for manipulating and storing dates in Java?

后端 未结 5 1556
夕颜
夕颜 2021-02-03 22:37

What is the Best Practice for manipulating and storing Dates e.g. using GregorianCalendar in an enterprise java application?

Looking for feedback and I will consolidate

5条回答
  •  难免孤独
    2021-02-03 23:15

    Joda is the way to go. Why ?

    1. it has a much more powerful and intuitive interface than the standard Date/Time API
    2. there are no threading issues with date/time formatting. java.text.SimpleDateFormat is not thread-safe (not a lot of people know this!)

    At some stage the Java Date/Time API is going to be superseded (by JSR-310). I believe this is going to be based upon the work done by those behind Joda, and as such you'll be learning an API that will influence a new standard Java API.

提交回复
热议问题