关于LocalDateTime

public static void main(String[] args) {


        //获取当前时间
        LocalDateTime nowTime= LocalDateTime.now();


        //自定义时间
        LocalDateTime endTime = LocalDateTime.of(2017, 10, 22, 10, 10, 10);


        //比较  现在的时间 比 结束时间之后  返回的类型是Boolean类型
        SystemnowTime.isAfter(endTime));


        //比较   现在的时间 比 结束时间之前  返回的类型是Boolean类型
        System.out.println(nowTime.isBefore(endTime));


        //比较  两个时间是否相等
        System.out.println(nowTime.equals(endTime));

  //转换 将LocalDateTime 转成Date

  Date.from(nowTime.atZone(ZoneId.systemDefault()).toInstant())
 }

posted @ 2020-07-23 20:56  panda's  阅读(138)  评论(0编辑  收藏  举报