| Author |
string to date parsing ....
|
sekhar sp
Greenhorn
Joined: Aug 31, 2008
Posts: 2
|
|
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
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
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
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: string to date parsing ....
|
|
|