SSN
SSN

Reputation: 169

how to convert seconds_since_the_beginning_of_this_epoch to date format in java..?

How to convert seconds_since_the_beginning_of_this_epoch (ssboetod) to date format in java..?

for example:
I will have number in ssboetod format:

987777000

And I want it to be in normal date format:

Fri Apr 20 20:00:00 2001.

Upvotes: 0

Views: 559

Answers (4)

Nishan
Nishan

Reputation: 2871

    long s = 987777000L * 1000L;
    Date d = new Date(s);
    System.out.println(d);

Upvotes: 0

Sai Kumar
Sai Kumar

Reputation: 2321

java.text.DateFormat

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1503924

If by "this epoch" you mean the normal unix epoch, you can just multiply by 1000:

Date dt = new Date(987777000000L);

Java dates are measured in milliseconds since the Unix epoch.

As ever though, I would strongly recommend that you look at using Joda Time instead of the built-in Java date/time APIs... Joda Time is much nicer. (You'd still use the same value to construct an Instant though.)

Upvotes: 5

Ingo
Ingo

Reputation: 36339

Look up the javadoc for java.util.Date(long)

Upvotes: 1

Related Questions