zoukankan      html  css  js  c++  java
  • java8的LocalDateTime与Date互相转换

    LocalDateTime转Date

    Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
    Date resultDate = Date.from(instant);
    

    Date转LocalDateTime

    LocalDateTime localDateTime = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
    

    LocalDateTime常用操作

    LocalDateTime localDateTime = dateTime.plusMonths(n).withHour(23).withMinute(59).withSecond(59).withNano(0);// 加n个月,设置23点59分59秒
    LocalDateTime localDateTime = dateTime.plusMonths(n).with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59).withNano(0);// 加n个月,月底那天
    
  • 相关阅读:
    apio2018题解
    ynoi2018
    hdu2036
    Morley's Theorem
    计算几何
    luogu1355 神秘大三角
    poj2398
    洛谷---小L和小K的NOIP考后放松赛
    LibreOJ β Round #7
    python3
  • 原文地址:https://www.cnblogs.com/ouyida3/p/9032585.html
Copyright © 2011-2022 走看看