• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

converting from timestamp to date

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have the following method



and to me, it should turn the long number, into whatever date that represents, and this works with some numbers. But when I try it with that number in the example (which I have just chosen arbitrarily), I get the error message(at compile time): integer number too large: 99500000000.

Anyway, I really don't understand why I am getting this error, and only this can sum up how I feel !

Please help!
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
integers have a maximum size(2^31-1=2147483647) and that number exceeds it. Use an integer that is equal or less then Integer.MAX_VALUE (use this to verify the maximum value).
[ April 28, 2006: Message edited by: Rusty Shackleford ]
 
David J Evans
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thanks for you reply.

I realise that the upper limit of an integer may be exceeded by that number, but I thought the long data type was for larger numbers?

Either way, what I want to achieve is turning a timestamp, back into a readable date, which I can do in PHP, so I'm sure java has a function to do it. The timestamp for about 2 minutes ago was this 1146261394418, which is 2 digits longer than the number in my example, but is returned through this function, as a long datatype.



So can anyone explain to me what's going on, or just simply, how I can turn my timestamp back into a human readable date.

Thanks
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're using an integer literal instead of a long literal. Change it to 9500000000L and it will work.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Technically I should say an "integer literal of type int instead of an integer literal of type long" since technically they're both integer literals, but you get the point.
 
David J Evans
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cheers ken, you're on the ball.
 
reply
    Bookmark Topic Watch Topic
  • New Topic