Compare dates ignoring milliseconds?

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

    You need to use

    cal.set(Calendar.MILLISECOND, 0);
    

    and possibly as well

    cal.set(Calendar.SECOND, 0);
    

    if you just need the minutes to match.

提交回复
热议问题