Reputation: 169
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
Reputation: 2871
long s = 987777000L * 1000L;
Date d = new Date(s);
System.out.println(d);
Upvotes: 0
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