aspose file tools*
The moose likes Beginning Java and the fly likes Date formatting in java. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date formatting in java." Watch "Date formatting in java." New topic
Author

Date formatting in java.

nazir ahmed
Greenhorn

Joined: Aug 02, 2008
Posts: 16
Hi,

i get a date value from My sql database(the field name start_date with data type "date").Also i insert the date value in following format yyyy-mm-dd format.i want to display in mm-dd-yyyy format .

i display the date value in the following format 2008-10-22 00:00:00.0.i want onlu mm-dd-yyyy format .please help
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi there, welcome to Java ranch. This question probably belongs in the Beginners Forum (and if you search there you'll find many answers to this question) but regardless of that:

Look at the DateFormat class(es) in particular SimpleDateFormat, you'll quickly see what to use.

Hope that helps!


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
James Basller
Ranch Hand

Joined: Sep 07, 2008
Posts: 58
Originally posted by nazir ahmed:
Hi,

i get a date value from My sql database(the field name start_date with data type "date").Also i insert the date value in following format yyyy-mm-dd format.i want to display in mm-dd-yyyy format .

i display the date value in the following format 2008-10-22 00:00:00.0.i want onlu mm-dd-yyyy format .please help


Yes that's right!!!

You can achieve this by using SimpleDateFormat class and pass whatever format you want in it's constructor
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date formatting in java.