我有这段代码
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);
}
}
我的输出结果如下:
为什么日期由20变成了19呢?I/flutter ( 5209): 日期是 2019-11-20T00:00:00.000+08:00
I/flutter ( 5209): dateTime (2019-11-19 16:00:00.000Z)
I/flutter ( 5209): 现在改为了 19/11/2019