12345678910111213141516171819202122232425262728293031323334353637383940 |
- package cn.com.ty.lift.common.utils;
- import cn.hutool.core.date.BetweenFormater;
- import cn.hutool.core.date.DateUtil;
- import java.time.LocalDate;
- import java.time.ZoneId;
- import java.time.ZonedDateTime;
- import java.util.Date;
- public class DateUtils {
- /**
- * LocalDate转Date
- *
- * @param localDate
- * @return
- */
- public static Date localDate2Date(LocalDate localDate) {
- if (null == localDate) {
- return null;
- }
- ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
- return Date.from(zonedDateTime.toInstant());
- }
- /**
- * 生成当前时间的年月日时分秒毫秒微秒
- *
- * @return
- */
- public static String generateCode() {
- return DateUtil.format(new Date(), "yyyyMMddHHmmssSSS");
- }
- public static void main(String[] args) {
- System.out.println(DateUtil.formatBetween(1212112121, BetweenFormater.Level.SECOND));
- }
- }
|