LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 04: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, 05: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



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 04:20 AM
Get the epoch date of a file helptonewbie Linux - General 3 08-15-2007 07:46 AM
Webalizer - howto convert the trafic into human readable? sys7em Linux - Server 3 09-25-2006 04:48 AM
java date and time manipulation? trscookie Programming 1 07-13-2006 06:51 PM
Epoch time the other way! michedlp Programming 0 04-25-2004 03:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:01 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
Open Source Consulting | Domain Registration