I am trying to format some dates using the Java Date class. I have some long values that I have gotten through previous calculations. Before I start formatting any dates I have a list of longs, they are as follows.
-12345
0
12345
I do some basic formatting like this...
DateFormat df = new SimpleDateFormat("dd/MMM/yyyy HH:mm:ss");
String formattedDate = df.format(new Date(dateNumber.longValue()));
Because Java uses the start of 1970 as a base my expected output would be something like
31/Dec/1969 23:59:47
01/Jan/1970 00:00:00
01/Jan/1970 00:00:12
However the output I am actually getting is
31/Dec/1969 18:59:47
31/Dec/1969 19:00:00
31/Dec/1969 19:00:12
I am a bit confused as to why they are all on December the 31 rather than split between December 31 and January 1. Due to the face that the second two numbers in the list are positive I cannot figure out why the date would be anything before 1970. If anyone can help me out with this using basic Java libraries I'd much appreciate it.