LocalDateTime计算时间差

Stella981
• 阅读 907

LocalDateTime 为java8的新特性之一


LocalDateTime.now() 获得当前时间

java.time.Duration duration = java.time.Duration.between(LocalDateTime   startTime,  LocalDateTime  endTime );


例如:     duration.toMinutes()    //两个时间差的分钟数

toNanos()//纳秒

toMillis()//毫秒

toMinutes()//分钟

toHours()//小时

toDays()//天数


原文地址:https://blog.csdn.net/shaoyu_zhu_88/article/details/77148557

点赞
收藏
评论区
推荐文章
Easter79 Easter79
2年前
sql:mysql:函数:TIMESTAMPDIFF函数实现TimeStamp字段相减,求得时间差
<divclass"htmledit\_views"id"content\_views"<p&nbsp;函数内指定是minute,则最终结果value值的单位是分钟,如果函数内指定为hours,则最终结果value值单位为小时。</p<preclass"has"name"code"<codeclass"hljssql"<
Wesley13 Wesley13
2年前
Java面试
<divclass"htmledit\_views"id"content\_views"<pid"maintoc"<strong目录</strong</p<pid"Java%E5%9F%BA%E7%A1%80%EF%BC%9Atoc"style"marginleft:40px;"<ahref"Java%E5%
Wesley13 Wesley13
2年前
Java中Class对象详解
<divclass"htmledit\_views"id"content\_views"<phttps://blog.csdn.net/mcryeasy/article/details/52344729<br</p<p待优化整理总结</p<p</p<h1style"padding:0px;fontfamily:'apple
Wesley13 Wesley13
2年前
Activiti 工作流入门指南
<divclass"htmledit\_views"id"content\_views"<h1<aname"t0"</a概览</h1<p如我们的介绍部分所述,Activiti目前分为两大类:</p<ul<li<p<ahref"https://activiti.gitbook.io/activiti7deve
Easter79 Easter79
2年前
Tomcat8及之后版本出现的The valid characters are defined in RFC 7230 and RFC 3986
<divclass"htmledit\_views"id"content\_views"<p升级tomcat8及更高版本带来的问题</p<p由于使用get请求,链接中参数携带特殊字符,由于Tomcat的新版本中增加了一个新特性,就是严格按照RFC3986规范进行访问</p<h2<aname"t0"</a解析,而RFC
Stella981 Stella981
2年前
Linux下CPU占用率高分析方法
<divclass"htmledit\_views"id"content\_views"<p一、可能有线程一直占用CPU资源</p<p1.先通过ps查看进程状态,找出进程的PID(8209)。</p<p2.jstackl8209&gt;/usr/local/work/tomcat/8209.stack导出PID
Stella981 Stella981
2年前
Python基础教程,Python入门教程(非常详细)
<divclass"htmledit\_views"id"content\_views"<p<ahref"http://c.biancheng.net/python/base/"rel"nofollow"第1章Python编程基础</a</p<p1.<ahref"http://c.biancheng.net/view/
Wesley13 Wesley13
2年前
Java 9版本之后Base64Encoder和Base64Decoder无法继续使用解决办法
<divclass"htmledit\_views"id"content\_views"<p在项目开发过程中,因为重装系统,安装了Java10版本,发现sun.misc.Base64Encoder和sun.misc.Base64Decoder无法使用。</p<p<br</p<p<strong原因:</strong</p<p查看
Stella981 Stella981
2年前
CodeBlocks下载与安装教程
<divclass"htmledit\_views"id"content\_views"<p一、下载教程</p<p1.在浏览器上搜索CodeBlocks官网或者直接输入网址<ahref"http://www.codeblocks.org/"rel"nofollow"http://www.codeblocks.org/进入Co
Stella981 Stella981
2年前
Neo4j 的一些使用心得
<divclass"htmledit\_views"id"content\_views"<p<br</p<p<spanstyle"color:rgb(70,70,70);fontfamily:simsun;fontsize:14px;lineheight:21px;"由对图数据的处理需求,看到了图数据库(GraphData