This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes date order change,,, Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "date order change,,," Watch "date order change,,," New topic

date order change,,,

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I declared a column in table as:

The date set in table is of type yyyy-mm-dd .Is this default? I want to change it to dd-mm-yyyy as my values to be set in the table are of the form dd-mm-yyyy

My DB is MySql... how do i change it?
Jan Cumps

Joined: Dec 20, 2006
Posts: 2562

Hi. The database does not store your date in that format. Your query tool shows it like that, but internally, the date is stored as a numeric value.
You can use the MySQL date formatting functions to show the date as you please.

In a java program, you could format the date using java.text.SimpleDateFormat. To convert your dd-mm-yyyy from String to Date, you can use SimpleDateFormat.parse(). You can then insert that Date in your database. Here is an example of both cases.

Regards, Jan

OCUP UML fundamental and ITIL foundation
I agree. Here's the link:
subject: date order change,,,
It's not a secret anymore!