Click to See Complete Forum and Search --> : How to convert the given date (Wed May 10 00:00:00 IST 2006) in the dd-MM-yyyy format


avik2k1
06-09-2006, 08:56 AM
Hi All,

I am facing the problem for converting the date, which is coming in a dd-MM-yyyy format as an example '09-06-2006'. I have to convert it in dd-MM-yyyy format into a date object.

After parsing the string the date comes like (Wed May 10 00:00:00 IST 2006)

Please help me.

Khalid Ali
06-09-2006, 11:51 AM
SimpleDateFormat allowes you to do such tasks...if you are unable to do that..post your code as well as any error or full out put and what exactly is you expect to be a correct out put

avik2k1
06-12-2006, 12:32 AM
Hi,

My code is

String value="09-06-2006";
SimpleDateFormat df = new SimpleDateFormat("dd-mm-yyyy");
java.util.Date tDate = df.parse(value);
System.out.println("After Conversion the Date="+tDate);

Now I want the tDate in the dd-mm-yyyy format. but it's coming in
"Mon Jan 09 00:06:00 IST 2006" format.

Please help.

Khalid Ali
06-12-2006, 01:08 AM
you are missing just 1 tiny detail. As you can see you are trying to print the actual Date object which is printing correct values, and in reality you want to print the formatted date but you are not applying the format before u print it...make sense?
Just fo the following and u will get desired results
System.out.println("After Conversion the Date="+df.format(tDate));

avik2k1
06-12-2006, 01:34 AM
Hi,

It's printing in dd-MM-yyyy format only.
But I want to return this date in a java.util.Date object format to other function. I am facing the problem here. It's saying "incompatible types"

Khalid Ali
06-12-2006, 08:15 AM
there are 2 things here. whne u want to print you need to use the formatter and when u perform any other tasks on date, in those cases, you will need to use it as Date object

lalit112
06-27-2006, 09:59 PM
Hi,
If you still have problem let me know i can give u code from my office computer.

lalit112
06-27-2006, 10:09 PM
Hi,
If you still have problem let me know i can give u code from my office computer.