DateTime对象在颤振中从TimeOfDay转换后始终包含分钟,如05

问题描述 投票:0回答:1

我使用TimePicker获取开始时间和结束时间。我在数据模型中使用DateTime对象。像这样将TimeOfDay转换为DateTime

  DateTime newTime = new DateTime(
                              startTime.year,
                              startTime.month,
                              startTime.day,
                              picked.hour,
                              picked.minute);

我使用此表格打印

DateFormat timeFormat = new DateFormat("hh:mm a");

但是newTime的分钟始终为05。DateTime.now()也将分钟打印为05,例如12:05 PM。

datetime flutter timepicker
1个回答
0
投票

我正在尝试使用错误的DateFormatter打印

使用中

DateFormat timeFormat = new DateFormat("hh:mm a");

而不是

DateFormat timeFormat = new DateFormat.jm();
© www.soinside.com 2019 - 2024. All rights reserved.