JavaSE进阶
10.8.4 与传统日期处理的转换
类 |
To 遗留类 |
From 遗留类 |
java.time.Instant与java.util.Date |
Date.from(instant) |
date.toInstant() |
java.time.Instant与java.sql.Timestamp |
Timestamp.from(instant) |
timestamp.toInstant() |
java.time.ZonedDateTime与java.util.GregorianCalendar |
GregorianCalendar.from(zonedDateTime) |
cal.toZonedDateTime() |
java.time.LocalDate与java.sql.Time |
Date.valueOf(localDate) |
date.toLocalDate() |
java.time.LocalTime与java.sql.Time |
Date.valueOf(localDate) |
date.toLocalTime() |
java.time.LocalDateTime与java.sql.Timestamp |
Timestamp.valueOf(localDateTime) |
timestamp.toLocalDateTime() |
java.time.ZoneId与java.util.TimeZone |
Timezone.getTimeZone(id) |
timeZone.toZoneId() |
java.time.format.DateTimeFormatter与java.text.DateFormat |
formatter.toFormat() |
无 |