LocalDateTime计算时间差

<div class="htmledit\_views" id="content\_views"> <p>LocalDateTime 为java8的新特性之一<br></p> <p><br></p> <p>LocalDateTime.now() 获得当前时间<br></p> <p></p> <h5> </h5><div style="margin-left:20px;"> <a href="" rel="nofollow"></a><a class="header" href="" rel="nofollow">java</a>.<a class="header" href="" rel="nofollow">time</a>.Duration&nbsp;duration = java.time.Duration.between(LocalDateTime &nbsp; startTime, &nbsp;LocalDateTime &nbsp;end<span style="font-weight:bold;">Time</span>&nbsp;);</div> <div style="margin-left:20px;"> <br></div> <div style="margin-left:20px;"> <br></div> <div style="margin-left:20px;"> 例如: &nbsp; &nbsp; duration.toMinutes() &nbsp; &nbsp;//两个时间差的分钟数<br></div> <div style="margin-left:20px;"> <br></div> <div style="margin-left:20px;"> toNanos()//纳秒<br></div> <div style="margin-left:20px;"> <br></div> <div style="margin-left:20px;"> toMillis()//毫秒<br></div> <div style="margin-left:20px;"> <br></div> <div style="margin-left:20px;"> <span style="font-weight:bold;">toMinutes()//<span style="font-weight:bold;">分钟</span></span><br></div> <div style="margin-left:20px;"> <br></div> <div style="margin-left:20px;"> toHours()//小时<br></div> <div style="margin-left:20px;"> <br></div> <div style="margin-left:20px;"> toDays()//天数<br></div>

<br><p>原文地址:https://blog.csdn.net/shaoyu_zhu_88/article/details/77148557</p> </div>

点赞
收藏

评论区

加载中...

相关推荐

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

sql:mysql:函数:TIMESTAMPDIFF函数实现TimeStamp字段相减,求得时间差

<divclass"htmledit\_views"id"content\_views"<p&nbsp;函数内指定是minute,则最终结果value值的单位是分钟,如果函数内指定为hours,则最终结果value值单位为小时。</p<preclass"has"name"code"<codeclass"hljssql"<

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%

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

Activiti 工作流入门指南

<divclass"htmledit\_views"id"content\_views"<h1<aname"t0"</a概览</h1<p如我们的介绍部分所述,Activiti目前分为两大类:</p<ul<li<p<ahref"https://activiti.gitbook.io/activiti7deve

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