网站文章在哪发布做seo,建筑公司企业愿景及理念模板,网络科技公司的经营范围怎么写,seo培训师问题#xff1a; 查看服务器时间是正确的,但输出出来的时间#xff0c;比此时多出来八个小时。这里直接把时间减去八个小时。 public static void main(String[] args) throws ParseException {// 设定原始时间格式try {SimpleDateFormat dateFormat new SimpleDateFormat( 查看服务器时间是正确的,但输出出来的时间比此时多出来八个小时。这里直接把时间减去八个小时。 public static void main(String[] args) throws ParseException {// 设定原始时间格式try {SimpleDateFormat dateFormat new SimpleDateFormat(EEE MMM dd HH:mm:ss z yyyy, Locale.ENGLISH);dateFormat.setLenient(false);// 设置时区否则会使用系统默认时区dateFormat.setTimeZone(TimeZone.getTimeZone(Asia/Shanghai));// 解析日期字符串Date date dateFormat.parse(Sun Jun 23 06:10:03 CST 2024);// 获取Calendar实例Calendar calendar Calendar.getInstance();calendar.setTime(date);// 减去8小时calendar.add(Calendar.HOUR_OF_DAY, -8);// 格式化输出结果Date updatedDate calendar.getTime();DateFormat sdf new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);System.out.println(sdf.format(updatedDate));} catch (Exception e) {e.printStackTrace();}}//输出结果2024-06-22 22:10:03