• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date formatting in java.

 
nazir ahmed
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
James Basller
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic