java中比较两个时间的差值

项目背景
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;
}

评论

h
hw_7864

⭐️ Admin快速开发: https://show.cool-admin.com/

赞 0
h
hw_7864

⭐️ 官方文档: https://cool-js.com

赞 0
h
hw_7864

⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld

赞 0