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;
}
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册⭐️ Admin快速开发: https://show.cool-admin.com/
赞 0⭐️ 官方文档: https://cool-js.com
赞 0⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld
赞 0