01. -->
public void uDateToLocalDateTime() {
date = new ();
Instant instant = ();
ZoneId zone = ();
LocalDateTime localDateTime = (instant, zone);
}
02. -->
public void uDateToLocalDate() {
date = new ();
Instant instant = ();
ZoneId zone = ();
LocalDateTime localDateTime = (instant, zone);
LocalDate localDate = ();
}
03. -->
public void uDateToLocalTime() {
date = new ();
Instant instant = ();
ZoneId zone = ();
LocalDateTime localDateTime = (instant, zone);
LocalTime localTime = ();
}
04. -->
public void localDateTimeToUdate() {
LocalDateTime localDateTime = ();
ZoneId zone = ();
Instant instant = (zone).toInstant();
date = (instant);
}
05. -->
public void localDateToUdate() {
LocalDate localDate = ();
ZoneId zone = ();
Instant instant = ().atZone(zone).toInstant();
date = (instant);
}
06. -->
public void LocalTimeToUdate() {
LocalTime localTime = ();
LocalDate localDate = ();
LocalDateTime localDateTime = (localDate, localTime);
ZoneId zone = ();
Instant instant = (zone).toInstant();
date = (instant);
}
示例如下:
/**
* String日期时间转换 LocalTime
* @param strDateTime 2018-09-28 17:07:05
* @return
*/
public static LocalTime strDateTime2LocalTime(String strDateTime){
LocalTime localTime = null;
if (!(strDateTime)){
SimpleDateFormat df =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date date = (strDateTime);
("时间:"+ date);
Instant instant = ();
ZoneId zone = ();
LocalDateTime localDateTime = (instant, zone);
localTime = ();
(localTime);
} catch (ParseException e) {
();
}
}
return localTime;
}
参考文章:
LocalDate与Date转化: /liusk/p/