-1
I’m making an application that reads an html page and gets some information, among them a date. This date is in Portuguese, in the following format: "23 March 2019". I wonder if you have any way to convert this into a Date object.
-1
I’m making an application that reads an html page and gets some information, among them a date. This date is in Portuguese, in the following format: "23 March 2019". I wonder if you have any way to convert this into a Date object.
0
I got it using the lib intl
of Dart in this way:
import 'package:intl/date_symbol_data_local.dart';
///Pega string no formato "23 março 2019" e adiciona os "de" ficando: "23 de março de ///2019"
String strDate = splitted[0];
var fullDate = strDate
.split(" ")
.map((s) => " de " + s)
.join()
.trim()
.split(' ')
.skip(1)
.join(' ');
initializeDateFormatting("pt_BR", null).then((_) {
DateFormat("dd MMMM yyyy");
var d = DateFormat.yMMMMd("pt_BR").parse(fullDate);
print('date: ${d}');
});
Browser other questions tagged date dart flutter
You are not signed in. Login or sign up in order to post.