public static ZonedDateTime changeShanghaiToUTC(String beijingDateTimeStr) {
DateTimeFormatter beijingFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.of("Asia/Shanghai"));
if (StringUtils.isBlank(beijingDateTimeStr)) {
return null;
}
ZonedDateTime beijingDateTime = ZonedDateTime.parse(beijingDateTimeStr, beijingFormatter);
return beijingDateTime.withZoneSameInstant(ZoneId.systemDefault());
}
String 类型 转 ZonedDateTime
最新推荐文章于 2023-06-06 01:01:39 发布