LocalDateTime计算时间差

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

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注