时间差的计算
来源:互联网 发布:linux dns配置文件view 编辑:程序博客网 时间:2024/06/07 17:42
SimpleDateFormat simpleFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
try {
Date xdsj = (Date) simpleFormat.parse("2017-09-18 10:10:30");
Date jzsj = (Date) simpleFormat.parse("2017-09-20 16:30:10");
long xdsjKs = xdsj.getTime();
long jzsjJs = jzsj.getTime();
long sjc = jzsjJs - xdsjKs;
int day = (int) (sjc / (1000 * 60 * 60 * 24));// 剩余的天数
int hour = (int) ((sjc % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));// 剩余的小时数
int minute = (int) (((sjc % (1000 * 60 * 60 * 24)) % (1000 * 60 * 60)) / (1000 * 60));// 剩余的分钟数
int second = (int) ((((sjc % (1000 * 60 * 60 * 24)) % (1000 * 60 * 60)) % (1000 * 60)) / 1000);
System.out.println("天:" + day + "小时:" + hour + "分钟:" + minute
+ "秒:" + second);
} catch (ParseException e) {
e.printStackTrace();
}
"yyyy-MM-dd HH:mm:ss");
try {
Date xdsj = (Date) simpleFormat.parse("2017-09-18 10:10:30");
Date jzsj = (Date) simpleFormat.parse("2017-09-20 16:30:10");
long xdsjKs = xdsj.getTime();
long jzsjJs = jzsj.getTime();
long sjc = jzsjJs - xdsjKs;
int day = (int) (sjc / (1000 * 60 * 60 * 24));// 剩余的天数
int hour = (int) ((sjc % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));// 剩余的小时数
int minute = (int) (((sjc % (1000 * 60 * 60 * 24)) % (1000 * 60 * 60)) / (1000 * 60));// 剩余的分钟数
int second = (int) ((((sjc % (1000 * 60 * 60 * 24)) % (1000 * 60 * 60)) % (1000 * 60)) / 1000);
System.out.println("天:" + day + "小时:" + hour + "分钟:" + minute
+ "秒:" + second);
} catch (ParseException e) {
e.printStackTrace();
}
阅读全文
0 0
- vc 时间差的计算
- VC++时间差的计算
- C# 时间差的计算
- 计算日期的时间差
- 计算时间差的方法
- python 时间差的计算
- 时间差的计算
- C#中时间差的计算
- 计算时间差的JAVASCRIPT函数
- C#中时间差的计算
- Oracle计算时间差的方法
- C#中时间差的计算
- C#中时间差的计算
- 计算两个日期的时间差
- C#中时间差的计算
- C#中时间差的计算
- C#中时间差的计算
- C#中时间差的计算
- android问题记录IndexNotReadyException
- 配置com.alibaba.druid.pool.DruidDataSource数据源时出现的异常
- 深度学习的异构硬件加速:TPU 特性与数据中心的 ASIC 应用(概述篇)
- constraintlayout
- RxJava flatMap操作符用法详解
- 时间差的计算
- more effective C++在未来时态下发展程序
- C#梳理【委托Delegate】
- jfinal结合easyui完成基本的增删改查操作
- 重载 覆盖 隐藏
- Linux 常 用 命 令
- Windows Server 2012 R2 单网卡/单 IP 配置 VPN 服务
- SD卡彻底格式化
- kotlin 在fragment使用这个extensions的时候