i have a dateTime like this 2022-08-27T12:03:03.484Z
, i try to create a methode to remove the character T and Z :
My methode
String ConverTime(String varia) {
DateTime parseDate =
new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(varia);
var inputDate = DateTime.parse(parseDate.toString());
var outputFormat = DateFormat('MM/dd/yyyy hh:mm a');
var outputDate = outputFormat.format(inputDate);
return outputDate;
}
so i got this error:
The name 'DateFormat' isn't a class.
Try correcting the name to match an existing class.dartcreation_with_non_type
how can i solve it
CodePudding user response:
To use DateFormat
class, you need to import intl
package.
Open the pubspec.yaml
file and add these line below dependencies
section:
intl: ^0.17.0
Example:
dependencies:
intl: ^0.17.0
0.17.0
is the current version.
You can find more information at https://pub.dev/packages/intl