Is there a way to set the default DateFormat class used for parsing strings into dates?
My background: I get exceptions reading date values from JDBC because the date string is not in the expected format.
(text added on 2011-07-22):
Seems I need to precise my question description: I use a foreign, proprietary database together with a proprietary JDBC driver. There is no possibility to know or even change the column type on database side. When I try to read the ResultSet columns via ResultSet.getDate() or ResultSet.getObject() some exception is triggered inside the JDBC driver like “10 Jul 1999 is not a valid date”. What I want to achieve is to avoid this internal exception by setting some appropriate global default date format. Maybe I would need to implement some custom Locale first and the install that Locale globally?
You can set your default Locale:
Alternatively, you can use one of the
DateFormatstatic methods which accepts a Locale to just get the format for the Locale you’re interested in. If your date format doesn’t match one of the standard ones, you’ll need to create your ownSimpleDateFormat(based on a pattern) and make sure you always use that one instead of the default one.