File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes VERY URGENT Please help me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "VERY URGENT Please help me" Watch "VERY URGENT Please help me" New topic
Author

VERY URGENT Please help me

koray guclu
Ranch Hand

Joined: Feb 23, 2001
Posts: 59
Hi,
I have a project I use locales in that project to format the dates. I must use mm.dd.yyyy pattern. I use MSSQL server. I get the dates in dd.mm.yyyy format. There is not any problem when I get this and format this.
But I have a problem when I try to insert or update dates. Server excepts dd.mm.yyyy format. and end users enters the dates in mm.dd.yyyy format I used the following structure in my JSP page
I want to convert mm.dd.yyyy format to dd.mm.yyyy format. I get the start_date as a parameter of JSP page
----------------------
Locale currentLocale = new java.util.Locale("en", "US");
DateFormat currentDateFormatter = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT, currentLocale);
String start_date=request.getParameter("StartDate");
System.out.println(start_date);
SimpleDateFormat formatter = new SimpleDateFormat ("mm.dd.yyyy");
start_date = formatter.format(new java.util.Date(start_date));
start_date=currentDateFormatter.format(new java.util.Date(start_date));
----------------------
Thanks,

-----------------------------------------------------<BR> Koray GUCLU ~ the sky has no limit ~<BR> (B.s. Computer Engineer)<BR> Frankfurt am Main, Germany<BR> web : <A HREF="http://www.geocities.com/korayguclu/<BR rel="nofollow">" TARGET=_blank>http://www.geocities.com/korayguclu/<BR></A> mail: korayguclu@yahoo.com<BR>-----------------------------------------------------
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Dates, aren't they just lovely. It can be hard not to make an absolute mess of them...
When using dates in queries, inserts and other DML statements, I religiously stick to PreparedStatements. They're more efficient anyway as they can be cached. And you can just call PreparedStatement.setDate() without worrying about date formats at all. If you must, really really must, generate your own string representation for the date, use a java.sql.Date to do it for you. It will generate a SQL-92 standard date representation. But really, use a PreparedStatement.
- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: VERY URGENT Please help me