File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Spring in Action
this week in the
string to date parsing ....
Joined: Aug 31, 2008
Aug 31, 2008 08:12:00
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.
strDate = "14/08/2008";
df = new
Date tempDate = df.parse(strDate);
System.out.println(" DATE format ="+tempDate);
DATE format =Thu Aug 14 00:00:00 IST 2008
Joined: Sep 28, 2004
Aug 31, 2008 08:59:00
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.
Java Threads, 3rd Edition
Jini in a Nutshell
Java Gems (contributor)
I agree. Here's the link:
subject: string to date parsing ....
Code review required for converting dateformat
date format conversion to MM/dd/yyyy hh:mm a
Behaviour of parse() method in SimpleDateFormat
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014