Class ZoneKit

java.lang.Object
org.miaixz.bus.core.xyz.ZoneKit

public class ZoneKit extends Object
ZoneIdTimeZone相关封装
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • ZONE_UTC

      public static final TimeZone ZONE_UTC
      UTC 的 ZoneID
    • ZONE_ID_UTC

      public static final ZoneId ZONE_ID_UTC
      UTC 的 TimeZone
  • Constructor Details

    • ZoneKit

      public ZoneKit()
  • Method Details

    • toTimeZone

      public static TimeZone toTimeZone(ZoneId zoneId)
      ZoneId转换为TimeZonenull则返回系统默认值
      Parameters:
      zoneId - ZoneIdnull则返回系统默认值
      Returns:
      TimeZone
    • toZoneId

      public static ZoneId toZoneId(TimeZone timeZone)
      TimeZone转换为ZoneIdnull则返回系统默认值
      Parameters:
      timeZone - TimeZonenull则返回系统默认值
      Returns:
      ZoneId
    • getTimeZoneByOffset

      public static TimeZone getTimeZoneByOffset(int rawOffset, TimeUnit timeUnit)
      获取指定偏移量的可用时区,如果有多个时区匹配,使用第一个
      Parameters:
      rawOffset - 偏移量
      timeUnit - 偏移量单位
      Returns:
      时区
    • getAvailableID

      public static String getAvailableID(int rawOffset, TimeUnit timeUnit)
      获取指定偏移量的可用时区ID,如果有多个时区匹配,使用第一个
      Parameters:
      rawOffset - 偏移量
      timeUnit - 偏移量单位
      Returns:
      时区ID,未找到返回null