How to convert seconds_since_the_beg开发者_如何学Cinning_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.
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.)
Look up the javadoc for java.util.Date(long)
java.text.DateFormat
long s = 987777000L * 1000L;
Date d = new Date(s);
System.out.println(d);
精彩评论