项目背景
1.某篇文稿的发布时间是publishDate,例如:2020-07-21 18:00:41。
2.现要求判断该篇文稿的发布时间是否在近30天之内。
public static long dayDiff(Date currentDate,Date publishDate){
Long currentTime = currentDate.getTime();
Long publishTime = publishDate.getTime();
long diff = currentTime-publishTime;
long day = diff/(1000_60_60*24);
return day;
}
java中比较两个时间的差值
点赞
收藏