Compare dates ignoring milliseconds?

前端 未结 10 1318
北海茫月
北海茫月 2021-02-08 06:36

Is there a way to compare two calendar objects, but ignore milliseconds?

I have written a test case that compared two calendar objects, but there is a p

10条回答
  •  时光取名叫无心
    2021-02-08 07:23

    If you use jodaTime, the setCopy("0") method returns a DateTime object with milliseconds set to 0 to make it easy to compare:

    DateTime dateTimeZerodMillis = new DateTime().millisOfSecond ().setCopy("0")
    

提交回复
热议问题