Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 1st, 2004, 09:48 AM
guyinATL guyinATL is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 2 guyinATL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool Parse Date/Time from MS ACCESS in Java

Hi

I have a field with Date/Time data type in an ACCESS table which gets a date by calling =Now() whenever a record is inserted.

I am retrieving this date in different .jsp files.

When i call DateFormat.getDateInstance().format(resultSet.getD ate("sDate"))
it formats it perfectly in "Apr 01, 2004", like i want it.

But im also using Java Taglibs in some .jsp files which use <sql:getColumn position=1 name=sDATE> and retrieve it using pageContext.getAttribute().

The point is i am receiving the date in a String at some places. when i try to parse it using DateFormat.getDateInstance().parse() i get a NumberFormatException saying could not parse "2004-04-01 00:00:00:00" probably because the date to string is storing a 0 value for the time portion.

How can i parse it or get around to recieve just the date part and format it like Apr 01, 2004 while in the ACCESS database dates are stored in the Short Date format like 4/1/2004.

Thanks!

Reply With Quote
  #2  
Old October 16th, 2004, 10:33 AM
michlmann michlmann is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 56 michlmann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
I don't know exactly about MS Access. But in general if you've declared a field in the database to be of type DATE (DATE/TIME), you should use java.sql.ResultSet#getTimestamp which returns an instance of java.sql.Timestamp which in turn is a subclass of java.util.Date.

Using Timestamp you don't need to parse, you only need to format the date...

Bye

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Parse Date/Time from MS ACCESS in Java


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway