Java 日期总结

java 日期操作

1
2
3
4
5
6
7
8
//java8
LocalDateTime today_start = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);//当天零点
LocalDateTime today_start = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);//当天23:59:59
today_start.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); //时间格式化
//LocalDateTime 转 Date
Date out = Date.from(today_start.atZone(ZoneId.systemDefault()).toInstant());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
sdf.format(out); //时间格式化