I used to convert UTC time to TimeZone time like this in Android Java now in flutter how can I achieve.
public static String getTimeFullDateStr(Date date, String timeZone) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("h:mma, MMM dd, yyyy", Locale.US);
TimeZone tz = null;
if (timeZone.equalsIgnoreCase("")) {
tz = TimeZone.getTimeZone("US/Pacific");
} else {
tz = TimeZone.getTimeZone(timeZone);
}
simpleDateFormat.setTimeZone(tz);
String formattedDate = simpleDateFormat.format(date);
formattedDate = formattedDate.replace("AM", "am").replace("PM", "pm");
return formattedDate;
}
This is what i'm doing now in Flutter but don't know how to pass the timezone
DateFormat("h:mma, MMM dd" )
.format(DateTime.parse(timeCreated))
.replaceAll("AM", "am")
.replaceAll("PM", "pm")