Make Strings Explicit
When debugging, tear apart complex statements to verify the pieces. In this case, move those row getter calls to separate lines, assigning the values to String variables.
Be Careful With Formatters
You need to carefully study the doc for formatters, and then double-check the pattern characters.
In your case:
- The format "dd-MM-yyyy" is for month as digits
- The format "dd-MMM-yyyy" is for month as text (name of month)
Example Code
String inputDigits = "08-06-2012";
String inputChars = "08-Jun-2013";
java.text.SimpleDateFormat formatDigits = new java.text.SimpleDateFormat( "dd-MM-yyyy" );
java.text.SimpleDateFormat formatChars = new java.text.SimpleDateFormat( "dd-MMM-yyyy" );
java.util.Date dateDigits = null;
java.util.Date dateChars = null;
try {
dateDigits = formatDigits.parse( inputDigits );
dateChars = formatChars.parse( inputChars );
} catch ( ParseException ex ) {
Logger.getLogger( App.class.getName() ).log( Level.SEVERE, null, ex );
}
Dump to console…
System.out.println( "dateDigits: " + dateDigits );
System.out.println( "dateChars: " + dateChars );
When run…
dateDigits: Fri Jun 08 00:00:00 PDT 2012
dateChars: Sat Jun 08 00:00:00 PDT 2013