• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

string to date parsing ....

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I execueted the following code, but i get the output of the date in different format ....can someone tell me wats wrong in this code.

I want the output of the date to be in "dd/MM/yyyy" format.


CODE:
String strDate = "14/08/2008";
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date tempDate = df.parse(strDate);

System.out.println(" DATE format ="+tempDate);


OUTPUT:
DATE format =Thu Aug 14 00:00:00 IST 2008
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The parse() method takes a string, in a particular format and gets you a date object. This date object doesn't retain this format, it is merely a representation of the date.

If you want to print in a particular format, either (1) use the original string, or (2) generate a new string with the format() method.

Henry
 
reply
    Bookmark Topic Watch Topic
  • New Topic