LocalDateTime转带时区日期

 java.sql.Timestamp timestamp = java.sql.Timestamp.valueOf(value.asText());
                LocalDateTime localDateTime = timestamp.toLocalDateTime();

                // 将GMT+8时间转换为UTC时间
                ZonedDateTime gmt8ZonedDateTime = localDateTime.atZone(ZoneId.of(this.timeZone.getID()));
                ZonedDateTime utcZonedDateTime = gmt8ZonedDateTime.withZoneSameInstant(ZoneId.of("UTC"));

                System.out.println("GMT+8时间: " + localDateTime);
                System.out.println("UTC时间: " + utcZonedDateTime.toLocalDateTime());

你可能感兴趣的:(java,开发语言)