Java8处理日期和时间

        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        LocalDateTime time = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
        String localTime = df.format(time);
        System.out.println("LocalDateTime转成String类型的时间,并将时分秒设为0:"+localTime);


        LocalDateTime ldt = LocalDateTime.parse("2018-05-15 15:32:59",df);
        System.out.println("String类型的时间转成LocalDateTime:"+ldt);

猜你喜欢

转载自blog.csdn.net/bc_aptx4869/article/details/80323752
今日推荐