Is there a way to parse the following date string as July 23 1916
rather than July 23 2016
?
System.out.println(new SimpleDateFormat("yy/MM/dd", Locale.US).parse("16/07/23"));
Is there a way to parse the following date string as July 23 1916
rather than July 23 2016
?
System.out.println(new SimpleDateFormat("yy/MM/dd", Locale.US).parse("16/07/23"));
The Java Doc (http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) says:
The method
SimpleDateFormat.set2DigitYearStart(Date)
can be used to fix the year.May be you are looking for this.
If I understand your question then yes,
Per the
SimpleDateFormat.set2DigitYearStart(Date)
javadoc,There is the method
set2DigitYearStart
that can be used for that. It allows you to specify a start date. The parsed date will be in the interval [start date, start date + 100 years].See the documentation for details.