alphaH 2 tuần trước cách đây
mục cha
commit
598386847e

+ 4 - 0
java/src/main/java/com/payment/platform/common/config/JacksonConfig.java

@@ -8,6 +8,8 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Primary;
 
+import java.util.TimeZone;
+
 @Configuration
 public class JacksonConfig {
 
@@ -18,6 +20,8 @@ public class JacksonConfig {
         mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
         mapper.registerModule(new JavaTimeModule());
         mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+        // 固定序列化时区为北京时间,否则 OffsetDateTime 会被序列化为 UTC(Z),前端显示少8小时
+        mapper.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
         return mapper;
     }
 }