我在开发过程中陷入困境,我有这样的要求,我需要找到两个日期之间的延迟,即..currentdate-date from database
我需要以dd:hh:mm
. 在参考了很多参考资料后,我发现了如何转换为单独的毫秒小时和分钟,但期待的是:如果结果是 X 毫秒,我需要以正确的日分钟和秒格式显示它
示例:2 天:03 分钟:46 秒
这是正在使用的代码:
Calendar calendar1 = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
calendar1.setTime(date);
calendar2.setTime(date1);
long milliseconds1 = calendar1.getTimeInMillis();
long milliseconds2 = calendar2.getTimeInMillis();
long diff = milliseconds1 - milliseconds2;
System.out.println("diff ::"+diff);
long diffSeconds = diff / 1000;
long diffMinutes = diff / (60 * 1000);
long diffHours = diff / (60 * 60 * 1000);
long diffDays = diff / (24 * 60 * 60 * 1000);
谁能建议我进一步做什么?请指导我..