Hi people,
I know that this is not a servlet especific question, but we
forwarded this to some list and got no answer.
We work with the date in the following format : DD/MM/YYYY.
The problem is that we area using the function bellow to convert a
string to date and having strange results:
public static java.sql.Date stringToSqlDate (String inData) {
SimpleDateFormat formatador = new
SimpleDateFormat("dd/MM/yyyy");
ParsePosition marcador = new ParsePosition(0);
java.util.Date auxData;
auxData = formatador.parse(inData,marcador);
java.sql.Date outData;
outData = new java.sql.Date(auxData.getYear(),
auxData.getMonth(), auxData.getDate());
return outData;
}
INPUT OUTPUT
------- -------
32/01/2001 01/02/2001
31/13/2001 31/01/2001
62/07/2001 31/08/2001
As you can see the function shifts the days or months if they area
invalid. I just would like to have a function to test if my date is correct
and have no shifting.
Can someone help us .
bye
jk
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html