1

from API I am getting this: "2022-05-12T15:55:03.000000Z" My question is, how can I make it: 12.05.2022, 15:55

My question is, is here any easy way? Otherwise I can slowly and partially convert it with string methods, but I guess there must be better, more proper way?

Thank you in advance

helloitme4
  • 41
  • 1
  • 3

1 Answers1

1

you can user DateFormat to get a date as string formatted the way you want

String x = "2022-05-12T15:55:03.000000Z";

DateTime y = DateTime.parse(x);
  final DateFormat formatter = DateFormat('dd.MM.yyyy, HH:mm');
  final String formatted = formatter.format(y);
  print(formatted); // 12.05.2022, 15:55
omar hatem
  • 1,799
  • 1
  • 10
  • 23
  • 1
    The [`DateFormat` class](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) can be found in the [`intl` package](https://pub.dev/packages/intl). – just95 May 14 '22 at 17:46