This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 18541
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to change the date,Time format after accessing it from the database
 
Similar Threads
How do I get date and time seperate from Date Object
System Date
xsd datetime format
Getting date as a string from util.date object in desired format format
Code for date comparison