Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 05-09-2008, 04:58 PM   #1
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
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



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 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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:30 AM.

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