• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange problem while accessing date type data columns

 
Abhinav Anand
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I designed an app that has to connect to a datasource through JDBC. In my current implementation i have chossen MS Access as the backend database.
No my database has a table that contains some date columns. The program is supposed to show the date in dd/mm/yyyy format. The program works fine on my computer and shows the date in the given format. But the moment i deploy my app on another computer the date format changes and starts displaying the date in mm/dd/yyyy format.
Why is this problem not occuring on my computer and why this date format problem arises when the program is run on another computer.
Any suggetions will be welcome.
Thanks,
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
don't waste your time trying to figure out the problem, just use the java.text.SimpleDateFormat in Java to format it for you. It will always be the same for all applications.
Jamie
 
Kevin Li
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jamie was right. You should use rs.getDate("data_col") to get a the Date object and then phase it to string by method in SimpleDateFormat class.
kevin
 
Abhinav Anand
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You guys are absolutely right in saying so.
I am using this implementation to extract the date columns from the result set.
But the problem I am facing is how to update or insert rows in a table with date columns that will ensure that the backend DBMS will proper format and accept my date.
As mentioned my app connects to MS Access. Now the problem is that my app works fine on my computer, but when I install the program to the clients computer, the program starts behaving abnormally. The classes which update tables with date columns or insert such rows in tables and worked perfectlly on my computer start updating table in such way that the day part of the date becomes the month part and the month part becomes the day part. Like:
month/day//year : 12/01/2002
becomes
month/day/year : 01/12/2002
It seems crazy but I can't simply understand that how my program can have different behavior on two different computer having same version of jre and MS Access.
To sum it up is there any way of updating i.e. altering a table in a way so that I can be assured of proper updation of the date columns. Like to extract date from the result set we have SimpleDateFormat class and the getDate.. implementation. Similary is there any such standard way of updating tables so that the date columns get updated according to the DBMS specification without me worrying about such things.
Any suggetions will be extremly welcome.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic