计算时间差隔多少分钟
来源:互联网 发布:百度网盘老是网络异常 编辑:程序博客网 时间:2024/04/19 04:01
public static void main(String args[]) {
String dateStart = "2016-12-26 15:00:00";
// String dateStop = "2016-12-26 15:25:48";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d1 = null;
Date d2 = new Date();
try {
d1 = format.parse(dateStart);
//毫秒ms
long diff = d2.getTime() - d1.getTime();
System.out.println(diff);
long diffSeconds = diff / 1000 % 60;
long diffMinutes = diff / (60 * 1000) % 60;
long diffHours = diff / (60 * 60 * 1000) % 24;
long diffDays = diff / (24 * 60 * 60 * 1000);
System.out.print("两个时间相差:");
System.out.print(diffDays + " 天, ");
System.out.print(diffHours + " 小时, ");
System.out.print(diffMinutes + " 分钟, ");
System.out.print(diffSeconds + " 秒.");
if(diffMinutes>30){
System.out.println("true");
}else{
System.out.println("false");
}
} catch (Exception e) {
e.printStackTrace();
}
}
String dateStart = "2016-12-26 15:00:00";
// String dateStop = "2016-12-26 15:25:48";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d1 = null;
Date d2 = new Date();
try {
d1 = format.parse(dateStart);
//毫秒ms
long diff = d2.getTime() - d1.getTime();
System.out.println(diff);
long diffSeconds = diff / 1000 % 60;
long diffMinutes = diff / (60 * 1000) % 60;
long diffHours = diff / (60 * 60 * 1000) % 24;
long diffDays = diff / (24 * 60 * 60 * 1000);
System.out.print("两个时间相差:");
System.out.print(diffDays + " 天, ");
System.out.print(diffHours + " 小时, ");
System.out.print(diffMinutes + " 分钟, ");
System.out.print(diffSeconds + " 秒.");
if(diffMinutes>30){
System.out.println("true");
}else{
System.out.println("false");
}
} catch (Exception e) {
e.printStackTrace();
}
}
0 0
- 计算时间差隔多少分钟
- 计算时间差获取大概的时间 如:多少秒前,多少分钟前
- javascript计算时间差,获取多少分钟多少秒 exmobi实现双击功能
- JS 计算时间差【单位:分钟】
- js求时间差 计算 天 小时 分钟
- php论坛中常用的两个时间差(多少分钟前,多少小时前,多少天前)
- php论坛中常用的两个时间差(多少分钟前,多少小时前,多少天前)
- delphi 计算文件与当前时间差(天小时分钟秒)
- delphi 计算文件与当前时间差(天小时分钟秒)
- Js计算时间差(天、小时、分钟、秒)
- NET计算时间差(天、小时、分钟、秒)
- Js计算时间差(天、小时、分钟、秒)
- Python 输入时间字符串以分钟单位计算时间差
- Js计算时间差(天、小时、分钟、秒)
- Excel计算时间差(精确到分钟、秒)
- Js计算时间差(天、小时、分钟、秒)
- lua计算时间差 按照日历方式来计算时间差 而不是固定每个月都是多少天来计算
- 时间差计算
- NanoPCT3开发板的安卓系统模块编译及烧录
- 关于Android依赖库文件的一些经验
- MPU6050使用dmp时,Pitch范围只有-90-90的问题
- htm页面l导出excel表格
- 启动页的主题
- 计算时间差隔多少分钟
- Java重写的方法和覆盖
- 487
- c# asp.net excel导出 80070005 拒绝访问
- 计算文章发表的天数是几天后
- Excel单元格下拉框引用其它Sheet中的值的方法
- navicate连接远程oracle链接 报cannot create oci enviroment 怎么办?
- RelativeLayout中的参数说明
- 关于HTTP状态码500错误和localhost无法访问