Example #1
0
  /**
   * 将SnmpVar转换为int
   *
   * @param xVar SnmpVar
   * @return int
   * @throws Exception
   */
  public static long snmpVar2Long(SnmpVar var) {
    long result = 0;
    if (var instanceof SnmpInt) {
      SnmpInt intVar = (SnmpInt) var;
      result = intVar.longValue();
    } else if (var instanceof SnmpGauge) {
      SnmpGauge gauge = (SnmpGauge) var;
      result = gauge.longValue();
    }

    return result;
  }
Example #2
0
 /**
  * 将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;
 }
Example #3
0
  /**
   * 将SnmpVar转换为时间
   *
   * @param xVar SnmpVar
   * @return
   * @throws Exception
   */
  public static Long snmpVar2Timeticks_Long(SnmpVar var) { // 改写方法返回String
    Long resu = 0L;
    if (var == null) {
      return resu;
    }
    if (var instanceof SnmpTimeticks) {
      SnmpTimeticks loSnmp = (SnmpTimeticks) var;
      resu = loSnmp.longValue();
    }
    if (var instanceof SnmpGauge) {
      SnmpGauge timeVar = (SnmpGauge) var;
      resu = timeVar.longValue();
    } else if (var instanceof SnmpInt) {
      SnmpInt timeVar = (SnmpInt) var;
      resu = timeVar.longValue();
    }

    return resu;
  }