昨天 d5bbd17a1428811da046ec3be3c0cc943a7ae059
src/main/java/com/ruoyi/common/utils/DateUtils.java
@@ -3,11 +3,7 @@
import java.lang.management.ManagementFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.*;
import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;
@@ -45,10 +41,9 @@
    public static LocalDate toLocalDate(Date date){
        if(date == null) return LocalDate.now();
        // 2. 指定固定时区转换(如东八区UTC+8、UTC零时区)
        return date.toInstant()
                .atZone(ZoneId.of("Asia/Shanghai")) // 东八区(北京/上海时区)
                // .atZone(ZoneId.of("UTC")) // 可选:UTC零时区
        // java.sql.Date.toInstant() 会抛 UnsupportedOperationException,需先转为 java.util.Date
        Instant instant = new java.util.Date(date.getTime()).toInstant();
        return instant.atZone(ZoneId.of("Asia/Shanghai"))
                .toLocalDate();
    }