java.time.LocalDateTime.until() 方法示例 java.time.LocalDateTime.truncatedTo() 方法示例 java.time.LocalDateTime.with() 方法示例 java.time.LocalDateTime.until() 方法示例 package com.codingdict; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; public class LocalDateTimeDemo { public static void main(String[] args) { LocalDateTime date = LocalDateTime.parse("2017-01-03T10:15:30"); LocalDateTime date1 = LocalDateTime.now(); System.out.println(date.until(date1, ChronoUnit.HOURS)); } } java.time.LocalDateTime.truncatedTo() 方法示例 java.time.LocalDateTime.with() 方法示例