This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Wrongly Date is updated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Wrongly Date is updated" Watch "Wrongly Date is updated" New topic
Author

Wrongly Date is updated

RH KA
Greenhorn

Joined: Mar 27, 2009
Posts: 1
Hello,

I tried to insert the date in the format dd/MM/yyyy into the mysql where the format is yyyy-MM-dd. Please see the screnario below

The issue was, the entered month is taken as date and entered date is taken as month.

So if the date entered is 13, then month is become 1 (13 - 12) and remaining 12 month is added in the year.

For example, when the date 03/13/2008 is entered , it is saved in data base as 2009-01-03.

For example, when the date 03/27/2008 is entered , it is saved in data base as 2010-03-03.

(27 = 2 years 3 months. so 2008 become 2010 and 27 - 24 become as 03 )

But before this issue is fixed, there were around 5000 records inserted in the DB. Now we can not ask the customer to reenter the dates. Is there any possibility to find the correct date from this wrong date?

Thanks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13872
    
  10

RH KA, please check your private messages for an administrative matter. You can see them by clicking My Private Messages.

No, there is no way you can repair that, because information on the correct date has been lost because of the error.

For example, if the date in the database is 2009-01-03, how do you know if the user entered 1 March 2009 or 13 March 2009 or something else? There's no way to distinguish between the different possibilities, so it is impossible to repair this.

I'm afraid there is nothing you can do other than ask the customer to reenter the dates.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1966
    
    7

Are you working with JDBC or SQL? You can try using the java.text.SimpleDateFormat to ensure the format is yyyy-mm-dd or whatever you like before updating the field.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wrongly Date is updated
 
Similar Threads
Capture month and year from user input date
Capture month and year from user input date
Capture month and year from user input date
Java Calendar - add
Code review required for converting dateformat