// 通过时分秒构造偏移量(使用很方便,推荐)
System.out.println(ZoneOffset.ofHours(8)); //+08:00
System.out.println(ZoneOffset.ofHours(-5)); //-05:00
System.out.println(ZoneOffset.ofHoursMinutes(8, 8)); //+08:08
System.out.println(ZoneOffset.ofHoursMinutesSeconds(8, 8, 8)); //+08:08:08
System.out.println(ZoneOffset.ofTotalSeconds(8 * 60 * 60)); //+08:00
// 当前时区的偏移量
System.out.println(OffsetDateTime.now().getOffset()); // +08:00
System.out.println(ZonedDateTime.now().getOffset()); // +08:00
// 特殊偏移量
System.out.println("最小偏移量:" + ZoneOffset.MIN); //-18:00
System.out.println("最小偏移量:" + ZoneOffset.MAX); //+18:00
System.out.println("中心偏移量:" + ZoneOffset.UTC); //Z
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。