DateTimeFormatter 格式化时间工具类 主要是与Date之间的转化

时间:2025-04-02 07:21:53

// 01. -->
public void DateToLocalDateTime() {
date = new ();
Instant instant = ();
ZoneId zone = ();
LocalDateTime localDateTime = (instant, zone);
}

// 02. -->
public void DateToLocalDate() {
date = new ();
Instant instant = ();
ZoneId zone = ();
LocalDateTime localDateTime = (instant, zone);
LocalDate localDate = ();
}

// 03. -->
public void DateToLocalTime() {
date = new ();
Instant instant = ();
ZoneId zone = ();
LocalDateTime localDateTime = (instant, zone);
LocalTime localTime = ();
}


// 04. -->
public void LocalDateTimeToDate() {
LocalDateTime localDateTime = ();
ZoneId zone = ();
Instant instant = (zone).toInstant();
date = (instant);
}


// 05. -->
public void LocalDateToDate() {
LocalDate localDate = ();
ZoneId zone = ();
Instant instant = ().atZone(zone).toInstant();
date = (instant);
}

// 06. -->
public void LocalTimeToDate() {
LocalTime localTime = ();
LocalDate localDate = ();
LocalDateTime localDateTime = (localDate, localTime);
ZoneId zone = ();
Instant instant = (zone).toInstant();
date = (instant);
}