From 14c10d5021513463109aa800aeb3e8dbf479b05c Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期四, 28 八月 2025 10:58:11 +0800 Subject: [PATCH] update --- ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java index 3df99a9..326ebb6 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java @@ -138,6 +138,37 @@ } /** + * 获取当前UTC+8时间的ISO 8601格式字符串 (例如: 2018-02-12T15:30:20+08:00) + * + * @return 当前UTC+8时间的ISO 8601格式字符串 + */ + public static String getUtc8Time() + { + return OffsetDateTime.now(ZoneOffset.of("+8")).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + /** + * 获取当前UTC时间的ISO 8601格式字符串 (例如: 2018-05-26T00:35:30Z) + * + * @return 当前UTC时间的ISO 8601格式字符串 + */ + public static String getUtcTime() + { + return Instant.now().toString(); + } + + /** + * 将指定日期转换为UTC时间的ISO 8601格式字符串 (例如: 2018-05-26T00:35:30Z) + * + * @param date 指定日期 + * @return UTC时间的ISO 8601格式字符串 + */ + public static String getUtcTime(Date date) + { + return date.toInstant().toString(); + } + + /** * 计算相差天数 */ public static int differentDaysByMillisecond(Date date1, Date date2) -- Gitblit v1.7.1