toDateFromUTC static method

String toDateFromUTC(
  1. int year,
  2. int month,
  3. int day, [
  4. TimeFormats timeFormat = TimeFormats.none,
  5. DateFormats dateFormat = DateFormats.none,
  6. String? pattern,
  7. String separator = "",
  8. String? local,
])

Converts UTC components to a formatted date string.

Example:

String utcDate = DateProvider.toDateFromUTC(2024, 2, 6);
print(utcDate);  // Output: "06-02-2024"

Implementation

static String toDateFromUTC(
  int year,
  int month,
  int day, [
  TimeFormats timeFormat = TimeFormats.none,
  DateFormats dateFormat = DateFormats.none,
  String? pattern,
  String separator = "",
  String? local,
]) {
  if ((year + month + day) > 0) {
    return DateTime.utc(year, month, day).toDate(
      timeFormat: timeFormat,
      dateFormat: dateFormat,
      format: pattern,
      separator: separator,
      local: local,
    );
  } else {
    return '';
  }
}