@Component
public class TimeUtils {
private static final DateTimeFormatter localDateTimeFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
public static Date LocalDateTimeToDate(LocalDateTime localDateTime) {
try {
String localDateTimeString = localDateTimeFormat.format(localDateTime);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return simpleDateFormat.parse(localDateTimeString);
} catch (Exception e) {
throw new CloudnaException(ErrorCode.UNKNOWN_ERROR, "LocalDateTime转Date失败");
}
}
}
localdate转date工具类
最新推荐文章于 2023-12-24 18:02:51 发布