I am working on multi country application, user can login from any country, now I need to convert my Date in PST time zone. Every time it will get user time zone and convert it into "America/Los_Angeles" (PST) time zone, and it will return date object with converted date.
There may be other problems, but the main thing I see is that Date doesn't have a Timezone associated with it.
It's always milliseconds from the Epoch.
The display format used determines what TimeZone you see.
Roopesh Rana wrote:I got some thing, but this is also giving wrong result,
If the thing that is incorrect is 'theResult' then, again, it is a Date object, which has no concept of Timezone.
When you print out a Date it is formatted based on your systems Timezone by default.
Now you are using the DateTime class, which is from the Joda Time library (?), instead of java.util.Date.
Joda Time's DateTime class does have timezone information, in contrast to java.util.Date.
Note that lines 4 and 5 really have no effect, since you're not doing anything with the return values of the methods that you are calling.
When you convert the DateTime to a jav.util.Date in line 5, you will lose the timezone information again (simply because java.util.Date does not store this information), so this doesn't really help you anything.