使用LocalDateTime计算两个时间的差
LocalDateTime now = LocalDateTime.now();
System.out.println("计算两个时间的差:");
LocalDateTime end = LocalDateTime.now();
Duration duration = Duration.between(now,end);
long days = duration.toDays(); //相差的天数
long hours = duration.toHours();//相差的小时数
long minutes = duration.toMinutes();//相差的分钟数
long millis = duration.toMillis();//相差毫秒数
long nanos = duration.toNanos();//相差的纳秒数
System.out.println(now);
System.out.println(end);
System.out.println("发送短信耗时【 "+days+"天:"+hours+" 小时:"+minutes+" 分钟:"+millis+" 毫秒:"+nanos+" 纳秒】");
使用LocalDateTime计算两个时间的差的更多相关文章
- oracle计算两个时间的差值(XX天XX时XX分XX秒)
在工作中需要计算两个时间的差值,结束时间 - 开始时间,又不想在js里写function,也不想在java里去计算,干脆就在数据库做了一个函数来计算两个时间的差值.格式为XX天XX时XX分XX秒: 上 ...
- Oracle 计算两个时间的差值
有两个日期数据START_DATE,END_DATE,欲得到这两个日期的时间差(以天,小时,分钟,秒,毫秒):天:ROUND(TO_NUMBER(END_DATE - START_DATE))小时:R ...
- javascript计算两个时间的差
function GetDateDiff(startTime, endTime, diffType) { //将xxxx-xx-xx的时间格式,转换为 xxxx/xx/xx的格式 startTime ...
- 求计算两个时间的差(DateTime类和TimeSpan类)
日期时间数据是项目设计过程中经常需要处理的信息,C#提供了DateTime类和TimeSpan类来处理日期时间数据.下面介绍说明Datetime类和TimeSpan类的使用 //初始化DateTime ...
- moment实现计算两个时间的差值
var m1 = moment('2018-08-14 11:00:00'), m2 = moment('2018-08-14 12:10:00'); console.log(m1)console.l ...
- Java计算两个时间的天数差与月数差 LocalDateTime
/** * 计算两个时间点的天数差 * @param dt1 第一个时间点 * @param dt2 第二个时间点 * @return int,即要计算的天数差 */ public stat ...
- C#计算两个时间年份月份差
C#计算两个时间年份月份差 https://blog.csdn.net/u011127019/article/details/79142612
- C#计算两个时间年份月份天数(根据生日计算年龄)差,求时间间隔
C#计算两个时间年份月份差 DateTime dt1 = Convert.ToDateTime("2008-8-8"); DateTime dt2 = System.DateTim ...
- MySql计算两日期时间之间相差的天数,秒数,分钟数,周数,小时数
MySql计算两日期时间之间相差的天数,秒数,分钟数,周数,小时数 计算两日期时间之间相差的天数,秒数,分钟数,周数,小时数,这里主要分享的是通过MySql内置的函数 TimeStampDiff() ...
随机推荐
- Vue修改单个组件的背景颜色
组件默认背景颜色为白色,但工作需要改成黑色,于是研究了一番. 很简单,只需在组件中使用两个钩子函数beforeCreate (),beforeDestroy () 代码如下: beforeCreate ...
- MySQL学习——数据类型
MySQL学习——数据类型 摘要:本文主要学习了MySQL数据库的数据类型. 整数类型 MySQL主要提供的整数类型有tinyint.smallint.mediumint.int.bigint,其属性 ...
- C#中在定义事件委托时怎样跨窗体传递参数
场景 C#中委托与事件的使用-以Winform中跨窗体传值为例: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100150700 ...
- FCC---Change Animation Timing with Keywords--两个小球从A都B,相同循环时间 duration, 不同的速度 speed
In CSS animations, the animation-timing-function property controls how quickly an animated element c ...
- curl ftp libcurl 功能使用
struct FtpFile { const char *filename; FILE *stream; }; static size_t my_fwrite(void *buffer, size_t ...
- iOS 禁用`URL Scheme`和`Universal Link`(通用链接)
为什么要禁用URL Scheme和Universal Link(通用链接) 通常我们APP中都会嵌套一些web页面,有时我们的web页面会被DNS劫持从而跳转到其他APP中:或者是某些APP的Univ ...
- linux系统管理-输入输出
目录 linux系统管理-输入输出 参数传递xargs linux系统管理-输入输出 重定向 将原本要输出到屏幕上的数据信息,重新定向到指定的文件中 运行程序,或者输入一个命令:默认打开4个文件描述符 ...
- OSI模型级各层功能
OSI(Open System Interconnection 即 开放系统互联)国际标准化组织(ISO)制定了OSI模型,该模型定义了不同计算机互联的标准,是设计和描述计算机网络通信的基本框架.OS ...
- VSCode 如何同步设置
微软新推出的 VSCode 是一款开源.轻量.良心的开发工具,一经问世,迅速受到全球广泛开发者的好评与青睐,威风之下有干掉 Sublime Text 的趋势.然而有不少 VSCode 使用者吐槽其不能 ...
- [Go] gocron源码阅读-go语言中的切片接口和类型综合
// getCommands func getCommands() []cli.Command { command := cli.Command{ Name: "web", Usa ...