ZoneDateTime 转换Date

Posted 吐槽村

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ZoneDateTime 转换Date相关的知识,希望对你有一定的参考价值。

final ZonedDateTime now = ZonedDateTime.now(); //当前时间
final ZonedDateTime todayZero = now.truncatedTo(ChronoUnit.DAYS); //今天的0点
final ZonedDateTime tomorrowZero = todayZero.plusDays(1); //明天的0点

final ZonedDateTime firstDayOfMonth = todayZero.withDayOfMonth(1); //当月1号0点
final ZonedDateTime nextDayOfMonth = firstDayOfMonth.plusMonths(1);//下月1号0点


final Date from = Date.from(todayZero.toInstant()); //ZoneDateTime 转换成Date

以上是关于ZoneDateTime 转换Date的主要内容,如果未能解决你的问题,请参考以下文章