My time: 1386696238
My code:
Date date = new Date(Long.parseLong(currentNotification.getDate_created()));
SimpleDateFormat formatter = new SimpleDateFormat("MM/DD/yyyy", Locale.getDefault());
String dateString = formatter.format(date);
My result: 1/16/1970
Desired result: 12/10/2013
What am I doing wrong?
Your value is in seconds, so you need to multiply it by 1000.
Also, DD is day of year, you want dd:
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault());
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