java - 两个日期之间的持续时间 Java
问题描述
我有 DateTime 字符串 2020-04-03 01:29:27 和 2020-04-03 01:29:37 我想以小时为单位获得持续时间。我已经尝试了很多东西,但这却找不到任何帮助
解决方案
I have tried many things but this but cant find any help
Do these "many things" include consulting the javadoc where you would find that:
// assuming both dates are in d1 and d2
Duration duration = Duration.between(d1, d2);
long hours = duration.toHours();
Hope that helps.
推荐阅读
- python-3.x - Python size by size 矩阵,允许输入和返回列表元素的列表
- android - 如何根据给定条件在活动的 onCreate 方法中显示按钮?
- ms-word - MS Office 更新到版本 13628.20274 后 Word 加载项的问题
- php - 如何隐藏电子邮件地址
- ruby - 用红宝石字母表中的数字位置替换字符串中的字母
- html - html 电子邮件 => 如何为被阻止的图像 (MSO) 设置背景颜色?
- c - 为什么字符值不在c中的整数值之后
- airflow - 气流服务器执行日期
- react-native - React-native 不支持 IPFS?
- symfony - OpenApiFactory 2.6.x 装饰上下文