• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Date formatting in java.  RSS feed

 
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
 
author
Posts: 3281
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!
 
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
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!