It appears nobody answered Karthick's question in 14 years. Better late than never:
A
Date represents a fixed point in time, and one should not consider it as a certain time in a certain timezone.
So while the
string "3:24:58 PM IST 2008-09-07" is different from the
string "10:54:58 AM BST 2008-09-07", when parsed both will yield equal
points in time, aka
Date.
That necessarily means that you can't convert a
Date to another timezone, because as we've seen, a fixed point in time is not associated with just one specific time zone.
Now, it's true that the
Date class contains a method
getTimezoneOffset() which implies that an instance of
Date keeps track of at least some timezone information, but you must ban this thought from your head. The
Date class does NOT represent looking at a clock in some timezone. The
Java designers have realized this, and have deprecated almost every method of
Date 25 years ago.
Karthick's solution should have looked something like this:
While the solution above works, it's dated. As of Java 8,
you should be using the
java.time packages instead: