Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Convert long to date

 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I've this long number,long temp=1018021774496
but I can't feed it into Date.
Date date=new date(temp);
it always say:
E:\PROGRA~1\JRun\servers\default\demo-app\WEB-INF\classes>e:\jdk122\bin\javac -d
eprecation search.java
search.java:31: Integer literal out of range. Decimal int literals must be in t
he range -2147483648 to 2147483647.
long l=1018021079797;
^
So how can I convert that "long" number to xx/xx/xx xx:xx ? Thanks!
 
Brett Anthoine
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ken,
Maybe I'm missing the point, but I tried that code and it worked fine :

I think you just missed the "l" after the constant and the compiler used it as an int, trying a conversion but it was out of range.
But I'm far from being an expert, so if anyone can confirm ?
Bye
 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh yeah, thanks, you are right, I missed out 'l', I seldom use long type, so don't know it need to add a 'l' at the end.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic