[SNMP4J] DateAndTime makeCalender improvement
Frank Fock
fock at agentpp.com
Wed Apr 20 15:22:42 CEST 2016
Hi Pim,
Yes, the issue is already fixed in the latest snapshot for some days now.
Best regards,
Frank
> On 20 Apr 2016, at 10:56, Pim Moerenhout <pim.moerenhout at gmail.com> wrote:
>
> Hi Frank,
> Could you reproduce the error with this snippet?
> Regards Pim
>
> 2016-04-09 18:40 GMT+02:00 Pim Moerenhout <pim.moerenhout at gmail.com <mailto:pim.moerenhout at gmail.com>>:
> Hi Frank,
>
> This test case test the GregorianCalendar with all possible timezones which
> fails with the 2.4.2 DateAndTime.makeCalendar
>
> public void testDateAndTime() throws Exception {
> // 1st april 2016 UTC 00:00:00
> long testMillis = 1459468800000L;
> for (String timeZoneId : TimeZone.getAvailableIDs()) {
> GregorianCalendar gc = new
> GregorianCalendar(TimeZone.getTimeZone(timeZoneId));
> gc.setTimeInMillis(testMillis);
> OctetString dateAndTime = DateAndTime.makeDateAndTime(gc);
> int error = DateAndTime.validateDateAndTime(dateAndTime);
> if (error != 0) {
> System.out.println("SNMP error: " + error);
> }
>
> // check the makeCalendar from the generated DateAndTime
> GregorianCalendar parsedGc = DateAndTime.makeCalendar(dateAndTime);
> long parsedGcMillis = parsedGc.getTimeInMillis();
> System.out.println(String.format("[%32s] The parsed millis %s: %5.1f
> hours (" + gc
> .getTime() + " " + parsedGc.getTime() + ")", timeZoneId,
> (parsedGcMillis != testMillis ? "differs" : "equals "),
> (parsedGcMillis - testMillis) / 3600000.0));
> }
> }
>
> Most timezones fail, except when using the default timezone (or equivalent).
>
> Regards, Pim
>
More information about the SNMP4J
mailing list