• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

java question (compilation problem)

notfred

Lifer
I have this line of code:

long start = Calendar.getTimeInMillis();

the class imports java.util.* which includes the Calendar class.

When I try to compile it, I get the error:

"non-static method getTimeInMillis() cannot be referenced from a static context"

WTF? Nothing I have declared is static... why is it doing this?
 
getTimeInMillis() is not a static method, which means you can't use Calendar.getTimeInMillis(). You have to instantiate a Calendar object and call it from there.
 
Originally posted by: PrincessGuard
getTimeInMillis() is not a static method, which means you can't use Calendar.getTimeInMillis(). You have to instantiate a Calendar object and call it from there.

Yep. You need to do:

Calendar myCal = new Calendar();
long start = myCal.getTimeInMillis();
 
Yeah... I jsut figured it out... and i tried it, and now it bitches about getTimeInMillis being protected. How the hell to I access a protected method of a class I didn't write?
 
Back
Top