/** * 将SnmpVar转换为时间,排除+8时区的问题 * * @param var * @return */ public static String snmpVar2Timeticks_String_TimeZone(SnmpVar var) { String resu = ""; if (var == null) { return resu; } if (var instanceof SnmpTimeticks) { SnmpTimeticks loSnmp = (SnmpTimeticks) var; resu = loSnmp.toString(); } if (var instanceof SnmpGauge) { SnmpGauge timeVar = (SnmpGauge) var; resu = DateFormatter.getLongDate((timeVar.longValue() - 8 * 3600) * 1000); } else if (var instanceof SnmpInt) { SnmpInt timeVar = (SnmpInt) var; resu = DateFormatter.getLongDate((timeVar.longValue() - 8 * 3600) * 1000); } return resu; }
/** * @param seconds 秒 * @param timeZone 减去的时区数目 * @return */ public static String dealWithTimeZone(String str, int timeZone) { Date temp; try { temp = DateUtils.parseDate(str, new String[] {DateFormatter.LONG_FORMAT.toPattern()}); } catch (ParseException e) { temp = new Date(); } long time = temp.getTime() - 3600L * 1000 * timeZone; return DateFormatter.getLongDate(time); }