LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-09-2008, 05:58 PM   #1
true_atlantis
Member
 
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Rep: Reputation: 30
Java Epoch time to Human Readable (using Date)


Im having a problem using java to convert from epoch timestamp to normal timestamp. it looks like you can create a Date object with the timestamp as the argument (Date x = new Date(1207747992) but that doesn't return the correct human readable timestamp for me. in the previous example, if I print x, I will get "Wed Jan 14 16:29:07 MST 1970", when in reality, it should be "2008-04-09 13:33:12"(obv different format)... am I missing something?
 
Old 05-09-2008, 06:13 PM   #2
true_atlantis
Member
 
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Original Poster
Rep: Reputation: 30
as soon as i posted this, i realized my problem

SQL's function 'to_unixtime' will return SECONDS from epoch

Java's Date Class uses MILLISECONDS from epoch - so multiply by 1000 and it works

IDIOT!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gawk/awk/tcsh - how to convert large number to human readable (Mb,Gb, etc)? BrianK Programming 23 10-30-2010 05:20 AM
Get the epoch date of a file helptonewbie Linux - General 3 08-15-2007 08:46 AM
Webalizer - howto convert the trafic into human readable? sys7em Linux - Server 3 09-25-2006 05:48 AM
java date and time manipulation? trscookie Programming 1 07-13-2006 07:51 PM
Epoch time the other way! michedlp Programming 0 04-25-2004 04:51 AM


All times are GMT -5. The time now is 10:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration