Server sends me time like this:
2012-06-08 17:00:00 +0100
I need to change it like HH:MM based on local time. For example this time is what time at Japan, India, US and etc.
How can I do this? Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Option 1: using
java.util.Date/Calendar:First you need to parse the value to a
Date, then reformat it in the format and time zoneyou’re interested in:
Option 2: using Joda Time
Joda Time is a much better date/time library for Java.
Note that you should only convert to/from string representations when you really need to. Otherwise, use the most appropriate type based on your usage – this is where Joda Time really shines.