Link to home
Start Free TrialLog in
Avatar of virendra032700
virendra032700

asked on

Displaying Date from MsAccess to a general format

I am getting a date from date field in MsAccess in a format of date and time(2000-01-12 12:03:45). Please write how to convert this to a display format of 01-Dec-2000.

Thank You,

Virendra
Avatar of dmaguillo
dmaguillo

Hi virendra. Two months ago i wrote some java code for date fields accesing. JDBC-ODBC return date and time Access format like "java.sql.Timestamp". Here u have an example:

....
Object dateField = r.getObject(column);
....
int myDay  = Integer.parseInt(dateField.toString().substring(0,2));
int myMonth  = Integer.parseInt(dateField.toString().substring(3,5));
int myYear = Integer.parseInt(dateField.toString().substring(6,8));
         
// ie2k    
if (myYear < 30)
  myYear = myYear+2000;
else
  myYear = myYear+1900;
           
// Timestamp: yyyy-mm-dd hh:mm:ss.fffffffff
Timestamp myDate = Timestamp.valueOf(myYear+"-"+myMonth+"-"+myDay+" 00:00:00.000000000");
....

Bye... :)
ASKER CERTIFIED SOLUTION
Avatar of Jim Cakalic
Jim Cakalic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial