[SNMP4J] Convert long to int?

Frank Fock fock at agentpp.com
Tue Jun 5 01:26:31 CEST 2007


Hi Phil,

The problem is, the System.currentTimeMillis() returns milli seconds
(1/1000s) and TimeTicks uses hundredths of seconds (1/100).
The factor 10 makes the difference, but even when dividing
System.currentTimeMillis() by ten, it will by too big for using
the value as a TimeTick.

Best regards,
Frank

PHIL BERGSTRESSER wrote:
> Frank,
>     I think this is begging the question. There is an SMIv2 RFC
> definition for TimeTicks:
> 
> -- hundredths of seconds since an epoch
> TimeTicks ::=
>     [APPLICATION 3]
>         IMPLICIT INTEGER (0..4294967295)
> 
>     This requires a long to be represented in Java. Your constructor
> requires a long which is consistent with that, so I don't know why Joel
> is having a problem.
>     What he uses it for is not relevant.
> Phil
> 
>> -----Original Message-----
>> From: snmp4j-bounces at agentpp.org 
>> [mailto:snmp4j-bounces at agentpp.org] On Behalf Of Frank Fock
>> Sent: Monday, June 04, 2007 5:24 PM
>> To: jtgoguen at gmail.com
>> Cc: snmp4j at agentpp.org
>> Subject: Re: [SNMP4J] Convert long to int?
>>
>> Hi Joel,
>>
>> As the name "TimeTicks" suggests, this type is NOT designed 
>> to hold a time value. To hold a time value, use the 
>> DateAndTime textual convention.
>>
>> Best regards,
>> Frank
>>
>> Joel Goguen wrote:
>>> I'm having some trouble creating a TimeTicks object.  The 
>> constructor 
>>> says to pass a long value, which I'm doing by calling 
>>> System.currentTimeMillis(), which is required since the device 
>>> receiving my traps displays the TimeTicks field as the 
>> current system 
>>> time.  However, when I pass this long value to TimeTicks, I get an 
>>> IllegalArgumentException, since the current system time is greater 
>>> than 2^32 - 1.  Is there any way to convert a long to fit into 
>>> TimeTicks that would preserve the current system time?
>>>
>> -- 
>> AGENT++
>> http://www.agentpp.com
>> http://www.mibexplorer.com
>> http://www.mibdesigner.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