dateToLocalDate/localDateToDate

/**
* date转 localdate
*
* @param date
* @return
*/
private static LocalDate dateToLocalDate(Date date) {

    logger.info("date转 localdate" + date);
    if (null == date) {
        return null;
    }
    return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}

/**
 * localdate 转 date
 *
 * @param localDate
 * @return
 */
private static Date localDateToDate(LocalDate localDate) {

    logger.info(" localdate 转 date" + localDate);
    if (null == localDate) {
        return null;
    }
    ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
    return Date.from(zonedDateTime.toInstant());
}
posted @ 2020-10-14 10:16  小傻孩丶儿  阅读(316)  评论(0编辑  收藏  举报