Home  >  Q&A  >  body text

java date calendar 有什么区别

很烦使用java 日期,转换特老火,
有时可用date,有时用calender,
请问你大侠们这个实质区别是什么?

怪我咯怪我咯2765 days ago369

reply all(2)I'll reply

  • 阿神

    阿神2017-04-18 09:52:34

    The simple difference is

    • java.util.Date is a date data

    • java.util.Calendar Used for date related calculations

    In addition, if you can’t find the function you need in Date, go to Calendar and find it. You will know which one can do what.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:52:34

    Although I don’t know, it’s quite interesting. The current usage of the Date class is generally to treat the date as a whole to perform some operations, such as Format, and Calendar seems to be specially designed to subdivide Date. Date's getXXX is now Deprecated, and the doc clearly states that You use the method corresponding to Calendar, and it feels like Calendar is designed to make up for Date design flaws or something.

    reply
    0
  • Cancelreply