This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Please help... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Please help..." Watch "Please help..." New topic
Author

Please help...

Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Dear Friends,
Let me be more specific...
I have a date format in my database like:
Fri Jan 04 14:41:20 PST 2002
and I have to read from table and reformat it and write in the table again like:
1/04/2002 (same date just format is different)
How can I do it?
Appriciate your help,
Elahe


Thanks,
Elahe
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Is this the same question???
If not, it won't take much to format it to what you want.
What is the column type of the Date you read from, and what is the column type of the date you write to? (Date, DateTime, VARCHAR...etc?) My example shows reading and writing to a Date column.
[ April 08, 2002: Message edited by: Jamie Robertson ]
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Jamie,
Yes it is the same question since I was thinking my question was not clear but after I tried your answer last night I found out that was exactly my answer, but I guess I am wrong in some part could you please help me on this(column name is submittedDate and it is 3rd column).
Many thnaks,
Elahe
Error-------
com/srs/bugtrack/Rdate.java [73:1] Type expected or missing '}'
Date day = new (rs.getDate(3).getTime());
^
com/srs/bugtrack/Rdate.java [75:1] Class SimpleDateFormat not found in type declaration or import.
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
------
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
BTW, I put this on tope of program as well:
import java.util.Date;
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Jamie,
Here is the last version and now I'm getting this error Exception occured
Message: $exceptionmsg
String: java.lang.NullPointerException
am I in right track?
Thanks,
Elahe
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

I made a couple of modifications: your previous code did not account for the possibility of null being returned from the database (thus the NullPointerException).

Jamie
[ April 09, 2002: Message edited by: Jamie Robertson ]
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Thank you so much Jamie but let me update you since I was supposed to make some changes yesterday...
Since submittedDate column type was varchar(20) so I couldn't use getDate() function and I rewised the code one more time base on this but the other side I created new table exactly like the old one just the submittedDate column type is Date so I have to read from old table and write to the new table...let me submitte new request to put my code I guess I forward this a lot.
Many thanks,
Elahe
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help...
 
Similar Threads
Need help in XSL
String date and Object date comparisons
problem while insert date data in mysql
How to grab current date
Date problem