LocalDateTime用法

public static String format(Date date, String pattern) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
        LocalDateTime localDateTime = dateToLocalDateTime(date);
        return localDateTime.format(dateTimeFormatter);
    }
public static Date parse(String date, String pattern) {
  DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
  LocalDateTime localDate = LocalDateTime.parse(date, dateTimeFormatter);
  ZoneId zone = ZoneId.systemDefault();
  ZonedDateTime dateTime = localDate.atZone(zone);
   return Date.from(dateTime.toInstant());
 }

你可能感兴趣的:(LocalDateTime用法)