Reputation: 2698
is it possible to convert this date "Fri, 12 Dec 2008 13:20:41"
to unixtime
(integer
) in java
. please provide me with hints/solution . Thanks in advance.
Upvotes: 0
Views: 502
Reputation: 2274
Be aware that the unix epoch time is defined in seconds, not milliseconds. Following that I improved blackbelts's answer:
SimpleDateFormat pattern = new SimpleDateFormat("EEE, dd MM yyyy HH:mm:ss");
Date date = pattern.parse("Fri, 12 Dec 2008 13:20:41")
long milliseconds = date.getTime();
long unixEpochTime = milliseconds / 1000;
Upvotes: 2
Reputation: 157437
SimpleDateFormat pattern = new SimpleDateFormat("EEE, dd MM yyyy HH:mm:ss");
Date date = pattern.parse("Fri, 12 Dec 2008 13:20:41")
long milliseconds = date.getTime();
Upvotes: 6