This may be a very basic question, but i could’nt find any satisfactory answers.Hope my doubts gets clear on stackoverflow.
Q 1. Suppose i have time in a different timezone and i want to convert it to a different timezone, what is the way to do it in Java?
Q 2. Is there any way to get timezone using JavaScript?
Q 3. A timezone is just the representation of time in a particular zone, but actually every zone is at the same time,just representation wise it may be different depending on geographical conditions. – Is this understanding Correct?
possible duplicate link
Create a formatter and set the timezone in there.
Internally,
java.util.Datejust stores milliseconds since the Epoch in the UTC timezone.When you use
Date.toString()ornew SimpleDateFormat()without a timezone, then the default timezone of your VM is used.So in a sense, Java always converts to your current/default timezone (unless you happen to be in UTC).
It depends. You can use
getTimezoneOffset()but that gives you only the offset. There is no API to get the client’s OSs timezone ID (likeUTC,Europe/Berlin, etc.)Not really. See above.