jim
jim

Reputation: 2195

Trouble creating a long

long timeStamp = 1312561140157; gives me an error saying that the litter is too large of type int

I know I can set a long to System.currentTimeMillis() and this number i used is an output from the currentTimeMillis().

Anyone know how to make a literal work when it is this big?

Upvotes: 1

Views: 72

Answers (2)

Hunter McMillen
Hunter McMillen

Reputation: 61512

When you create a long you need put an 'L' character at the end of the number.

example: long timeStamp = 1312561140157L;

You can use lowercase or uppercase 'L', but generally you should use uppercase because l can be easily confused with 1

Upvotes: 2

Petar Minchev
Petar Minchev

Reputation: 47373

Use this long timeStamp = 1312561140157L. Just append L to the end of the number.

Upvotes: 4

Related Questions