[SNMP4J] DateAndTime.makeCalendar
Juris Zubkans
juris.zubkans at gmail.com
Thu Jan 7 11:59:53 CET 2010
Hi
the agent function DateAndTime.makeCalendar
accepts only octet string with length=11,
however even validateDateAndTime say that sting with 8 elements is ok too.
i think the DateAndTime.makeCalendar should be able to create date from
element like this: "07:d6:09:0b:0e:14:26:03"
I have some agents which returns short strings and snmp-get from linux
package handles this fine
but with DateAndTime i get ArrayIndexOutOfBoundsException
if I change code like below, it works fine:
....
GregorianCalendar gc =
new GregorianCalendar(year, month-1, date, hour, minute, second);
gc.set(Calendar.MILLISECOND, deci*100);
if (dateAndTimeValue.length() == 11) {
String timezone = "GMT"+dateAndTimeValue.get(8)+
dateAndTimeValue.get(9)+":"+dateAndTimeValue.get(10);
GregorianCalendar tgc =
new GregorianCalendar(TimeZone.getTimeZone(timezone));
tgc.setTimeInMillis(gc.getTimeInMillis());
return tgc;
}
return gc;
}
juris
More information about the SNMP4J
mailing list