Convert Calendar object to Date object

Hi Friends

i am stuck in a issue for which i need your help.

i am trying to do a conversion between Date object to Calendar object.

Till now i was successful in converting the Date object to Calendar object.

below is the sample code to do that

String dtStr="2007/05/24";

SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");

Date dt = sdf.parse(dtStr);

Calendar cal = Calendar.getInstance();

cal.setTime(dt);

i am getting the output in following format

Thu May 24 00:00:00 IST 2007

and i am passing this Calendar object to a method XYZ(cal).

Now the problem is the conversion between Calendar object back to the Date object.

In another method PQR() i have to convert the Calendar object(cal in this case) to Date Object.

I am facing a problem to that this conversion.I have to convert this Calendar object back to Date object and get the Date object in the same manner as Thu May 24 00:00:00 IST 2007

Please can anybody provide me a piece of code to do this conversion .

it would be a great help for me as i am stuck with this issue for a long time.

Thanks & Regards

Vikeng

[1208 byte] By [vikenga] at [2007-11-27 6:42:50]
# 1
Calendar has a getTime method similar to setTime(), only the other way, i.e., it returns a Date object to you. Isn't that what you need?
OleVVa at 2007-7-12 18:13:13 > top of Java-index,Java Essentials,Java Programming...
# 2
try this..Date d = cal.getTime();
apanousisa at 2007-7-12 18:13:13 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks guysI implemented what you said and i am able to get Date object in the format that i wanted and the output that i desired.Thanks a lot again.RegardsVikeng
vikenga at 2007-7-12 18:13:13 > top of Java-index,Java Essentials,Java Programming...