Java准确计算Date相差天数 Java获取当前时间戳/时间戳转换
https://blog.csdn.net/qq_35890572/article/details/96427499
public static int getDayDiffer(Date startDate, Date endDate) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); long startDateTime = dateFormat.parse(dateFormat.format(startDate)).getTime(); long endDateTime = dateFormat.parse(dateFormat.format(endDate)).getTime(); return (int) ((endDateTime - startDateTime) / (1000 * 3600 * 24)); }
获取当天时间的开始时间戳
- 上一篇 »PHP一行代码获取时间戳
- 下一篇 »PHP的time函数返回时间不正确