diff --git a/zlmediakit-service/src/test/java/cn/skcks/docking/gb28181/test/MediaServiceTest.java b/zlmediakit-service/src/test/java/cn/skcks/docking/gb28181/test/MediaServiceTest.java index 01e21b5..83aa09b 100644 --- a/zlmediakit-service/src/test/java/cn/skcks/docking/gb28181/test/MediaServiceTest.java +++ b/zlmediakit-service/src/test/java/cn/skcks/docking/gb28181/test/MediaServiceTest.java @@ -1,5 +1,8 @@ package cn.skcks.docking.gb28181.test; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.date.ZoneUtil; import cn.skcks.docking.gb28181.common.json.JsonResponse; import cn.skcks.docking.gb28181.media.config.ZlmMediaConfig; import cn.skcks.docking.gb28181.media.dto.config.ServerConfig; @@ -14,7 +17,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit.jupiter.SpringExtension; -import java.util.List; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.util.*; @Slf4j @SpringBootTest @@ -36,4 +43,18 @@ public class MediaServiceTest { JsonResponse> test = zlMediaHttpService.getServerConfig(secret); log.info("{}", test); } + + @Test + void test(){ + long unix = 1692346604L; + Instant instant = Instant.ofEpochSecond(unix); + + log.info("{}", LocalDateTime.ofEpochSecond(unix, 0, TimeZone.getTimeZone("UTC").toZoneId().getRules().getOffset(instant))); + log.info("{}", LocalDateTimeUtil.of(instant, TimeZone.getTimeZone("UTC"))); + log.info("{}", LocalDateTime.ofEpochSecond(unix, 0, ZoneOffset.ofHours(0))); + + log.info("{}", LocalDateTime.ofEpochSecond(unix, 0, TimeZone.getTimeZone("Asia/Shanghai").toZoneId().getRules().getOffset(instant))); + log.info("{}", LocalDateTimeUtil.of(instant, TimeZone.getTimeZone("GMT+8"))); + log.info("{}", LocalDateTime.ofEpochSecond(unix, 0, ZoneOffset.ofHours(8))); + } }