[SNMP4J] Problem with classe DateAndTime (SNMP4J-agent)

Frank Fock fock at agentpp.com
Wed Nov 23 22:27:05 CET 2005


Hi Taoufik,

You are right (for the most part). Instead of adding one to the index 
values,
the index values have to decremented by one as follows:

  public static GregorianCalendar makeCalendar(OctetString 
dateAndTimeValue) {
    int year = (dateAndTimeValue.get(0) & 0xFF ) * 256 +
        (dateAndTimeValue.get(1) & 0xFF );
    int month = (dateAndTimeValue.get(2) & 0xFF );
    int date = (dateAndTimeValue.get(3) & 0xFF );
    int hour = (dateAndTimeValue.get(4) & 0xFF );
    int minute = (dateAndTimeValue.get(5) & 0xFF );
    int second = (dateAndTimeValue.get(6) & 0xFF );
    int deci = (dateAndTimeValue.get(7) & 0xFF );
    String timezone = "GMT"+dateAndTimeValue.get(8)+
                      dateAndTimeValue.get(9)+":"+dateAndTimeValue.get(10);
    GregorianCalendar gc =
        new GregorianCalendar(year, month, date, hour, minute, second);
    gc.set(Calendar.MILLISECOND, deci*100);
    gc.setTimeZone(TimeZone.getTimeZone(timezone));
    return gc;
  }

The validateDateAndTime  is also affected by this off-by-one bug.

BTW, the usmUserTable implementation currently does not implement
createAndGo user creation correctly. These and other fixes will be
part of the next (first beta) release which is planned for around New Year.

Best regards,
Frank

Taoufik BEN EZZAHHAF wrote:

>Hi every body,
>method validateDateAndTime below presents an anomalie,
>in fact
>      int month = (os.get(3) & 0xFF );
>      int date = (os.get(4) & 0xFF );
>      int hour = (os.get(5) & 0xFF );
>      int minute = (os.get(6) & 0xFF );
>      int second = (os.get(7) & 0xFF );
>      int deci = (os.get(8) & 0xFF );
>should look like: 
>      int month = (os.get(4) & 0xFF );
>      int date = (os.get(5) & 0xFF );
>      int hour = (os.get(6) & 0xFF );
>      int minute = (os.get(7) & 0xFF );
>      int second = (os.get(8) & 0xFF );
>      int deci = (os.get(9) & 0xFF );
>the same problem exists in method makeCalendar : 
>    String timezone = "GMT"+dateAndTimeValue.get(8)+
>                     
>dateAndTimeValue.get(9)+":"+dateAndTimeValue.get(10);
>
>Am i wrong?
>
>
>
>
>
>	
>
>	
>		
>___________________________________________________________________________ 
>Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
>Téléchargez cette version sur http://fr.messenger.yahoo.com
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>
>  
>


-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com





More information about the SNMP4J mailing list