| Author |
date format with MS Access database
|
Peter Primrose
Ranch Hand
Joined: Sep 10, 2004
Posts: 755
|
|
Here is something that drives me nuts: I am using my jdbc with MSdatabase. Everything works GREAT except the date's format. I am using the DD-MMM-YY format (e.g., 13-Oct-04 ) and the database saves it correctly (I initially set it up this way [data Type = Date/Time and format as above]). When I input a date and look at the table I can see that the format is saved as I wanted BUT when I retrieve the information, the format given is: 2004-10-13 00:00:00 I had to write a method to correct this format (eliminate the 00:00:00) but I feel it's very inefficient. I looked at the MSdb date type for date only - nothing. Anyone?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
|
How are you retrieving the info? As a String? As a java.sql.Date? If the latter, you can format it anyway you want to.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Peter Primrose
Ranch Hand
Joined: Sep 10, 2004
Posts: 755
|
|
|
as a string
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Peter, As Bear was getting at, use the getDate() method. This will return a Date object which you can then format using DateFormat. You just specify a formatter with the format of your choice.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: date format with MS Access database
|
|
|