简单粗暴上代码,把获取到http的响应头的GMT时间转换成北京时间
String urlStr = "http://aaa.bbb.cc/a.pdf";Set<String> headSet = new HashSet<>();headSet.add("Last-Modified");Map<String, Object> resultMap = HttpUtil.doGetHttpResponceHeader(urlStr, headSet);System.out.println("resultMap值=" + resultMap + "," + "当前类=HttpUtil.main()");String gmtTime = resultMap.get("Last-Modified").toString();SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss 'GMT'", Locale.US);Date date = dateFormat.parse(gmtTime);System.out.println("date=" + date + "," + "当前类=HttpUtil.main()");//加8个时区Calendar calendar = Calendar.getInstance();calendar.setTime(date);calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) + 8);date = calendar.getTime();SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String formatTime = sdf.format(date);System.out.println("formatTime=" + formatTime + "," + "当前类=HttpUtil.main()");