The following is driving me crazy, why am I getting the wrong calendar date when converting Unix Time 1386230874 using the code below!!
This should be Thu Dec 5 19:07:54 2013
Output:
Comment posted on:Sat Jan 17 11:03:50 EST 1970
Code:
Calendar facebook_created_time_calendar = Calendar.getInstance(TimeZone.getTimeZone("Australia/Sydney"));
facebook_created_time_calendar.setTimeInMillis(1386230874);
out.print("Comment posted on:");
out.println(facebook_created_time_calendar.getTime());
Java works with millisecond timestamps, while Unix time stamps are typically measured in seconds. Multiply the Unix timestamp by 1000L
to get the right time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With