mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-30 13:31:56 +08:00
升级spring-boot到最新版本2.6.4
This commit is contained in:
@@ -3,7 +3,11 @@ package com.ruoyi.common.core.utils;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ public class ExcelUtil<T>
|
||||
String dateFormat = field.getAnnotation(Excel.class).dateFormat();
|
||||
if (StringUtils.isNotEmpty(dateFormat))
|
||||
{
|
||||
val = this.parseDateToStr(dateFormat, (Date) val);
|
||||
val = parseDateToStr(dateFormat, (Date) val);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -703,7 +703,7 @@ public class ExcelUtil<T>
|
||||
String separator = attr.separator();
|
||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||
{
|
||||
cell.setCellValue(this.parseDateToStr(dateFormat, (Date) value));
|
||||
cell.setCellValue(parseDateToStr(dateFormat, (Date) value));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||
{
|
||||
@@ -1158,25 +1158,33 @@ public class ExcelUtil<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加ExcelUtil对java8 日期的支持
|
||||
* 格式化日期,日期可能是:{@link Date}、{@link LocalDateTime}、 {@link LocalDate} 其他日期暂不支持
|
||||
* 格式化不同类型的日期对象
|
||||
*
|
||||
* @param dateFormat 日期格式
|
||||
* @param val 被格式化的日期对象
|
||||
* @see DateUtils#parseDateToStr(String, Date)
|
||||
* @return 格式化后的日期字符
|
||||
*/
|
||||
private String parseDateToStr(final String dateFormat, Object val)
|
||||
public String parseDateToStr(String dateFormat, Object val)
|
||||
{
|
||||
if (val == null) {
|
||||
if (val == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
String str;
|
||||
if (val instanceof Date) {
|
||||
if (val instanceof Date)
|
||||
{
|
||||
str = DateUtils.parseDateToStr(dateFormat, (Date) val);
|
||||
} else if (val instanceof LocalDateTime) {
|
||||
}
|
||||
else if (val instanceof LocalDateTime)
|
||||
{
|
||||
str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDateTime) val));
|
||||
} else if (val instanceof LocalDate) {
|
||||
}
|
||||
else if (val instanceof LocalDate)
|
||||
{
|
||||
str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDate) val));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
str = val.toString();
|
||||
}
|
||||
return str;
|
||||
|
||||
Reference in New Issue
Block a user