在java中比较两个时间戳

2022-08-31 20:09:11

我如何比较 是否介于 和 之间:mytimefromtimetotime

Timestamp fromtime;
Timestamp totime;

Timestamp mytime;

答案 1
if(mytime.after(fromtime) && mytime.before(totime))
  //mytime is in between

答案 2

使用和方法: Javadocbeforeafter

if (mytime.after(fromtime) && mytime.before(totime))