【原创】 JAVA UTC时间转化为本地时间LocalDateTime

   public LocalDateTime convertUTCToLocalTime(String timeStamp) {
        Long timeLong = Long.parseLong(timeStamp) * 1000L;
        Date timeDate = new java.util.Date(timeLong);
        String date = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timeDate);
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime ldt = LocalDateTime.parse(date, df);
        return ldt;
    }

 

posted @ 2020-08-10 17:28  名成在天下  阅读(2651)  评论(0)    收藏  举报