Browse Source

升级spring-boot到最新版本2.6.4

tags/v3.5.0
RuoYi 3 years ago
parent
commit
a30622b460
  1. 2
      pom.xml
  2. 6
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/DateUtils.java
  3. 30
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java

2
pom.xml

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-boot.version>2.6.3</spring-boot.version>
<spring-boot.version>2.6.4</spring-boot.version>
<spring-cloud.version>2021.0.1</spring-cloud.version>
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
<alibaba.nacos.version>2.0.4</alibaba.nacos.version>

6
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/DateUtils.java

@ -3,7 +3,11 @@ package com.ruoyi.common.core.utils; @@ -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;

30
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java

@ -284,7 +284,7 @@ public class ExcelUtil<T> @@ -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> @@ -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> @@ -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;

Loading…
Cancel
Save