Compare dates ignoring milliseconds?

前端 未结 10 1273
北海茫月
北海茫月 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

    I'd recommend using Joda Time if you are performing anything beside the basic date manipulations. In your case you can truncate the dates like so and then compare :

    DateTime dateTime = new DateTime().millisOfDay().roundFloorCopy();
    

提交回复
热议问题