• 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

Convert Unix TimeStamp to Date Format

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

I have this code


this is the utput

java MyConsoleIO
Type some data for the program: 1194560520
input = Wed Jan 07 06:26:51 EST 1970


i should be gettong -

Thur Nov 08 2007 17:22 sometin like this

Please do help me out here

Thanks
Vivian Aranha
 
Vivian Aranha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it working all I had to do is put that freaking L behing the number...

Thanks for coming in
 
Sheriff
Posts: 22787
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could also have parsed the input into a long immediately:

This code immediately shows another improvement: the numeric primitive type wrappers have static methods called parseXXX, where XXX is the wrapper name. This will do the same as what you did, without creating a new object. In fact, this is what the Integer constructor that takes a string does:

So in fact, you're code is calling parseInt to get an integer, wrapping that integer into an Integer object, then retrieving the integer again.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic