I have a timestamp coming from an API in this format:
yyyy-MM-dd'T'HH:mm:ss.SSSSSS
I want to format it for the user in their own timezone (on android). This is what I'm doing:
String timestampFromApi = "...";
DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
Date date = df1.parse(timestampFromApi);
DateFormat df2 = new SimpleDateFormat();
Log.v(TAG, "In your timezone: " + df2.format(date));
But this prints the time in UTC. For example, if the timestamp happened at 4pm UTC time, and I am in PDT, the result is that it still prints "4pm".
I checked the timezone being used:
df2.getTimeZone()
and it does print out PDT for my device. What have I done wrong here?
Thanks