formatWithTimeZone static method

String formatWithTimeZone(
  1. DateTime date,
  2. String timeZone
)

Implementation

static String formatWithTimeZone(DateTime date, String timeZone) {
  int offset;
  try {
    offset = int.parse(timeZone);
  } catch (e) {
    throw ArgumentError('Invalid time zone format');
  }
  return DateFormat.yMd().add_jm().format(date.toUtc().add(Duration(hours: offset)));
}