btm me
btm me

Reputation: 653

change date format in flutter for json list particular data value

this is working Because String

TimeUtils.convertddMMMyy( 
    DateTime.parse(lowprice.paidOn!)
        ),


 static String convertddMMMyy(DateTime date) {
    final DateTime dateTime = date;
    final DateFormat formatter = DateFormat('yyyy-MMM-dd');
    final String formattedDate = formatter.format(dateTime);
    return formattedDate;

I need for a list , like below

CustomText(
    List[index].paidOn,
    color: ColorResource.appBarTextColor, ),

so how to change dateformat in list for flutter ? now its giving 01-03-2022 i need 01-mar-2022

Upvotes: 0

Views: 468

Answers (2)

btm me
btm me

Reputation: 653

It's working now

CustomText(
    TimeUtils.convertddMMMyy(
    DateTime.parse(List[index].paidOn!)),
    color: ColorResource.appBarTextColor,
),

Upvotes: 0

DholaHardik
DholaHardik

Reputation: 502

Did you tried this way?

convertDateFormat(lowprice.dateFrom!, "dd-MMM-yyyy")

//

String convertDateFormat(String date, String new_format) {
    DateTime dateTime = DateTime.parse(date);
    return DateFormat(new_format).format(dateTime);
}

Upvotes: 1

Related Questions