我尝试将String
换成 DATE TIME
,可是日期为什么会变?
if (obj.due_date != null) {
print('The date is '+obj.due_date);
print('now change to ' +
DateUtil().formattedDate(DateTime.parse(obj.due_date)));
}
DateUtil
import 'package:intl/intl.dart';
class DateUtil {
static const DATE_FORMAT = 'dd/MM/yyyy';
String formattedDate(DateTime dateTime) {
print('dateTime ($dateTime)');
return DateFormat(DATE_FORMAT).format(dateTime);
}
}
Output
I/flutter ( 5209): The date is 2019-11-20T00:00:00.000+08:00
I/flutter ( 5209): dateTime (2019-11-19 16:00:00.000Z)
I/flutter ( 5209): now change to 19/11/2019
why it will change from 20 to 19?
已解决