关于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())
}

浙公网安备 33010602011771号