Java: Difference between two dates spanning over months

前端 未结 4 1773
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 06:31

I have the following code that successfully gets me the difference between two days (in days, hours, minutes, seconds):

SimpleDateFormat format = new SimpleD         


        
4条回答
  •  独厮守ぢ
    2021-01-06 07:08

    I think you should look at joda-time library http://joda-time.sourceforge.net/

    Java default implementation of dates kind of suck, using joda time you can compute the intervals you want and its compatible with java Date class.

    http://joda-time.sourceforge.net/quickstart.html (look at interval and time periods)

提交回复
热议问题