This is odd... I don't understand what's happening. I'm trying to convert a
string to a util.date. Here's what I've got:
SimpleDateFormat fDate = new SimpleDateFormat ( "MM/dd/yy" );
String expDate = request.getParameter( "expDate" );
ParsePosition pos = new ParsePosition(0);
java.sql.Date sqlExpDate = null;
java.util.Date uDate = new java.util.Date();
if ( expDate.compareTo( "" ) != 0 ) {
out.println( "expDate = " + expDate + "<br>" );
out.println( "sqlExpDate before = " + sqlExpDate + "<br>" );
try {
uDate = ( java.util.Date )fDate.parse( expDate, pos );
out.println( "uDate = " + uDate + "<br>" );
sqlExpDate = new java.sql.Date(uDate.getTime());
} catch ( Exception e ) {
lError = lError.concat( "<font color=red>Expiration Date not valid</font><br>" );
expDate = "";
}
out.println( "sqlExpDate = " + sqlExpDate + "<br>" );
}
And here's what I'm getting:
expDate = 30/09/02
sqlExpDate before = null
uDate = Wed Jun 09 00:00:00 EDT 2004
sqlExpDate = 2004-06-09
This doesn't make sense to me... How is it turning Sept 30, 2002 into Jun 9, 2004?
I appreciate any help-
Thanks.