java8 常用日期函数

        Instant begin = Instant.now();
        Thread.sleep(500);
        System.out.println(Duration.between(begin, Instant.now()).toMillis());
        
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime time = LocalDateTime.now();
        System.out.println(pattern.format(time));
        System.out.println(LocalDateTime.parse("2020-02-11 12:12:12", pattern));
        
        System.out.println(pattern.format(time.plusMinutes(15)));

 

你可能感兴趣的:(J2SE)