I am trying to update date value which is in ISO format (with tz) 2020-11-22T10:02:13.501-04:00 to format like 11/Nov/2020 10:02 AM EST.
I am using the below code but how do we get the timezone as (-04:00) is EST.
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy HH:mm aa zzz");
Date dateVal = df2.parse(dateStr);
String formatted = sdf.format(dateVal);`
This format dd/MMM/yyyy HH:mm aa zzz will default to server timezone but I want the timezone from the date.
Don't include the timezone within the parse, it's just a notation.
And, when printing the value, the JVM is going to display the system's default time-zone, so manually append the time-zone text.