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 Beginning Java and the fly likes Date Formatting issue --- Plz 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 » Java » Beginning Java
Bookmark "Date Formatting issue --- Plz help..." Watch "Date Formatting issue --- Plz help..." New topic
Author

Date Formatting issue --- Plz help...

Abhishek Dwaraki
Ranch Hand

Joined: Feb 13, 2006
Posts: 44
Hey guys,
I'm using the SimpleDateFormat class to format my date and time in my program. The issue is that with the formatting of the system date, the am/pm marker is being returned in upper case. I need to store this in the database which could lead to issues later... Hence I need to format it in such a way that I obtain it in lowercase and I can't use the normal method of toLower() or anything like that.. I did not find any pattern string in the class that could return the marker in lowercase... Can someone help me out with this plzzzzzzzz....? Thanks in advance...


Regards,
Abhishek Dwaraki
Dept of Electrical and Comp Engg
University of Massachusetts, Amherst
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
you should not store the date as a string in the DB,
use setDate() method in PreparedStatement. then the JDBC driver will take care of this.

pascal
Abhishek Dwaraki
Ranch Hand

Joined: Feb 13, 2006
Posts: 44
The date is being stored as a Date object itself in the DB... And also the thing is i checked the documentation for the setDate() and setTime() methods in the PreparedStatement interface. I just specifies the MM.dd.yyyy format or the hh:mm:ss format. There is no mention of the AM/PM marker in the formatting. Plz do advice further in this regard. Thanks in advance.
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
where do you specify the date format pattern in PreparedStatement ??
Abhishek Dwaraki
Ranch Hand

Joined: Feb 13, 2006
Posts: 44
I'm not leaving the formatting to setDate() or rather don't want to take it till there. Want to just finish with the formatting in the Java code without going till the JDBC driver. All the same, I did check out the setDate() method only after you gave me the idea. The only parameters that it took was the index position and the date. The date object while being created took only one parameter to the constructor, that was the time or date, depending on the class being used. There is no place where to specify the format string. Or maybe I was not good enough to find it. Please advice in this regard Pascal ... Thanks a lot.
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
the formatting is done by the JDBC driver in the correct way (PreparedStatement is a interface which will be implemented by MySQL, Oracle, MSSql driver and so on).
so all you have to use is setDate() and do not care about the formatting.

you should not need to deal with formatting date for JDBC.

pascal
Abhishek Dwaraki
Ranch Hand

Joined: Feb 13, 2006
Posts: 44
Thanks a lot for the help pascal... It was a great help... Thanks once again...
 
Don't get me started about those stupid light bulbs.
 
subject: Date Formatting issue --- Plz help...
 
Similar Threads
format date
Bean:write + formatting dates
How to change Date Format
simple date format question
Difficulty assigning Java Util Date to TemporalType field in Entity Bean