aspose file tools*
The moose likes Beginning Java and the fly likes how to change the date,Time format after accessing it from the database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to change the date,Time format after accessing it from the database" Watch "how to change the date,Time format after accessing it from the database" New topic
Author

how to change the date,Time format after accessing it from the database

malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
Hi,
I want to know how to change the Date and Time format, after accessing it from the database.
I am getting the current date and time by:


In the database the datatype of dateTime column is datetime.
I am able to insert the current date and time into the database in "yyyy-mm-dd hh:mm:ss" format.

When I access it from the database, it returns the date and time in "yyyy-mm-dd hh:mm:ss" format,

How can change it into "hh:mm:ss dd-mm-yyyy" format???
Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You already know how to format a Date using any format you like. In fact you just posted an example of how to do it there. That's how you do it.

But don't say things like "the database formats a Date in such a way". It may have a default that it uses if a client asks it to display a Date in some string format, but that doesn't mean you have to do that. Don't do that. Get the column from the database as a Date and format it yourself. Which you already know how to do.
 
 
subject: how to change the date,Time format after accessing it from the database