public class TimeZoneUtils { // time 为时间戳 timeZone 为时区 public static String getTime(Long time,String timeZone ){ Date date1 = new Date(time); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 设置时区为中国标准时间(东八区) sdf.setTimeZone(TimeZone.getTimeZone(timeZone)); return sdf.format(date1); } }
Java 时间戳根据时区转化为格式为 “yyyy-MM-dd HH:mm:ss“ 的日期时间 工具类
最新推荐文章于 2024-01-08 08:22:43 发布