I am getting some data from the server and part of that data is a date. The date is in UTC format. I am showing time to the user in relative time using getRelativeTimeSpanString
.
Question
How can I convert a UTC time to the local time zone set on the users device.
This is how I'm getting date from server and using relativeTimeSpanString
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH).
parse("2014-05-21 12:21:41");
Date currentDate = new Date();
CharSequence cs = DateUtils.getRelativeTimeSpanString(date.getTime(), currentDate.getTime(), DateUtils.SECOND_IN_MILLIS);