Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert long to Object? 1

Status
Not open for further replies.

lbrechler

Programmer
May 17, 2001
44
US
I have some code that gets the current date/time using in a line that looks like this:

long time_of_msg = System.currentTimeMillis()/1000;

Now I would like to call the function
void setAttribute(String name, Object value)

and pass it the value of time_of_msg.

The compile is giving me the error "setAttribute(java.lang.String, java.lang.Object) in ... cannot be applied to (java.lang.String, long).

I have tried casting, "toString()", and everything else I can think to do, but it continues to throw errors.

Any suggestions?

Thanks in advance,
~Lindsay
 
try:

setAttribute( string, new Long( long ) );

The error is saying that you must pass that method an Object not a primative. You must use the wrapper class Long to use that method.

-gc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top