The following code:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd");
System.out.println(sdf.format(new Date(1293253200))); // 12/25/2010 05:00 GMT
System.out.println(sdf.format(new Date(1293339600))); // 12/26/2010 05:00 GMT
System.out.println(sdf.format(new Date(1293426000))); // 12/27/2010 05:00 GMT
prints:
01/16
01/16
01/16
Using a default DateFormat via SimpleDateFormat.getDateInstance(); prints these dates as 16-Jan-1970. What is going on?
You are mixing milliseconds and seconds. 1293253200 is indeed 16. January 2010. You have to multiply with 1000 to get the dates you wanted:
Date date = new Date(1293253200L*1000L);
Sat Dec 25 06:00:00 CET 2010
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