File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes How to Inserting current Date to DataBase Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to Inserting current Date to DataBase" Watch "How to Inserting current Date to DataBase" New topic

How to Inserting current Date to DataBase

prasant sahoo

Joined: Dec 14, 2007
Posts: 7
In my JSP I am sending the current date as follows

<%java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd");
String schduleDate = dateFormat.format(new java.util.Date());

<input type="text" name="scheduledDate" value="<%=dateFormat.format(new java.util.Date()) %>" readonly="true"/>

But in the DataBase (SQL) it is inserting 1/1/1900.
please help
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

The code you have shown is merely the code that displays the date in an input box. What does it look like on the screen? The way you expect?

Without further details regarding how that date -- remember that when it submitted it will just be a String value -- is being inserted into the database, I'm not sure anyone is going to be able to help you.
[ January 16, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
What is the database you're using,
If it was Oracle I have a way for you..

Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338

current date




I agree. Here's the link:
subject: How to Inserting current Date to DataBase
It's not a secret anymore!