timeCallHourFormat static method

dynamic timeCallHourFormat({
  1. String? date,
  2. String? locale,
})

Implementation

static timeCallHourFormat({String? date, String? locale}) {
  try {
    if (date?.isNotEmpty == true) {
      var time = date?.split("+");
      initializeDateFormatting(locale ?? "vi_VN");
      var inputFormat =
          DateFormat("yyyy-MM-dd'T'HH:mm:ss", locale ?? "vi_VN");
      var inputDate = inputFormat.parse(time![0]);
      var outputFormat = DateFormat('hh:mm a', locale ?? "vi_VN");
      var outputDate = outputFormat.format(inputDate);
      return outputDate.toUpperCase();
    } else {
      return "unknown";
    }
  } catch (e) {
    return "format error";
  }
}