Can convert date to long but long is too big?
eclipse, java
Solution
You just have to add a L after the literal:
long timeStamp = 1262347977927L;
Problem
I'm very confused right now. I have a `GregorianCalendar` object which I give a specific date (Jan 1st 2010). Calendar: ``` Calendar c = new GregorianCalendar(); c.set(2010, 0, 1); System.out.println(c.getTime()); System.out.println(c.getTimeInMillis()); ``` Output: Fri Jan 01 13:12:57 CET 2010 1262347977927 Now when I try to create a `long` and store this number in it, the number is actually too big for my variable. Storing in variable: ``` long timeStamp = 1262347977927; // ERROR: The literal 1262347977927 of type int is out of range ``` But when I store the result directly into my variable, it works just fine. Directly storing: ``` long timeStamp = c.getTimeInMillis(); System.out.println(timeStamp); ``` Output: 1262348451631 Why is the long that I get too big to be a long, yet not too long to be a long? I'm confused. I'm using Java 6 and Eclipse Indigo if anyone would want to know. EDIT: Thanks for all the instant answers... I feel really stupid now :p