This content has been marked as final. Show 3 replies
You are calling format with a long parameter. The only format that matches that signature that I can see would be Format.format(Object) assuming autoboxing is changing the long to a Long.
Format.format(Object) eventually calls DateFormat.format(Object, StringBuffer, FieldPosition). I have never used this method so I am not sure what it does.
Was your intention to actually call this method?
See the following example:
Edited by: jbish on Apr 26, 2013 12:43 PM
System.out.println("Test 1: " + frm.format(new Long(0l), new StringBuffer(), new FieldPosition(0))); System.out.println("Test 2: " + frm.format(new Long(-62167392000000l), new StringBuffer(), new FieldPosition(0))); Test 1: 19700101000000 Test 2: 00010101000000
Edited by: jbish on Apr 26, 2013 1:09 PM
There is no year 0.
1 A.D. immediately follows 1 B.C.
Call setLenient(false) on your SimpleDateFormat, and you will see that inputting the year 0 will throw a ParseException.
0 year should leniently be interpreted as 1 B.C. Include the era in your SimpleDateFormat to see if that's what it is doing:
SimpleDateFormat eraOnly = new SimpleDateFormat("G");