Long型转ZonedDateTime型


/**
* 将Long类型转化成0
* @author yk
* @param time
* @return
*/
public static ZonedDateTime toZonedDateTime(Long time){
public static final String LONG_DATE = "yyyy-MM-dd HH:mm:ss";
    SimpleDateFormat sdf = new SimpleDateFormat(LONG_DATE);
Date createDate = new Date(time);
String format = sdf.format(createDate);
DateTimeFormatter beijingFormatter = DateTimeFormatter.ofPattern(LONG_DATE).withZone(ZoneId.of("Asia/Shanghai"));
if(StringUtils.isBlank(format)){
return null;
}
ZonedDateTime beijingDateTime = ZonedDateTime.parse(format, beijingFormatter);
ZonedDateTime utc = beijingDateTime.withZoneSameInstant(ZoneId.of("UTC"));
return utc;

}
posted @ 2020-01-20 16:48  suke_123  阅读(1939)  评论(0编辑  收藏  举报