I want to calculate if a date retrieved from a database (in the normal Date form) is before or after the current one. Using "boolean equals(Date d)" won't work since the date is retrieved from the database as a string. How do I take this string and convert it to a date, d, so that I can use the above method? Thanks in advance, James
The simplest method, assuming that the date is stored as type "date" in your database is to retrieve it in its java-equivalent form. That is: java.sql.date xdate = (java.sql.Date) rs.getObject("xdate"); Please note that class java.sql.Date is NOT java.util.Date! If you can only get the date as a string, you have to either parse it out yourself and use the month/day/year form of the date constructor or use the Calendar class feature to do locale-sensitive construction.
Customer surveys are for companies who didn't pay proper attention to begin with.
I had a similar problem, and my solution was to create a DateUtil class specific to my DB - MSAccess. It implements Comparable, and returns the short date form. Yours would be similar. Hope that helps.