title: How to format DateTime in Flutter? Remove milliseconds in DateTime?
body: <p>As you seen, i have a custom DatePicker widget and it takes the <strong>currentTime</strong> in <strong>DateTime</strong> type.</p>
  <pre><code> DatePickerWidget(
                      currentTime: DateTime.now(),
                      text: &quot;$date1&quot;,
                      onChanged: (date) {
                        setState(() {
                          getProductDate(date.toString());
                          this.date1 = date.toString();
                        });
                      },
                      onConfirm: (date) {
                        setState(() {
                          getProductDate(date.toString());
  
                          this.date1 = date.toString();
                        });
                      },
                    ),
  </code></pre>
  <p>but it's give me milliseconds too.</p>
  <p><a href="https://i.stack.imgur.com/BLUjD.png" rel="noreferrer">result</a></p>
  <p><strong>Result</strong></p>
  <p>YYYY-MM-JJ  HH-MM:00.000</p>
  <p>How can I remove the :00.000 part in DateTime type?</p>
  <p>I just want to this format: <strong>'yyyy-MM-dd'</strong>.</p>
  <p>But <strong>currentTime</strong> is getting only <strong>DateTime</strong> type.</p>
  <p>is there any idea?</p>
  <p>my DatePickerWidget code:</p>
  <pre><code>class DatePickerWidget extends StatelessWidget {
    final Function(DateTime data) onChanged;
    final Function(DateTime data) onConfirm;
    final String text;
    final DateTime currentTime;
  
   
   
  
    const DatePickerWidget(
        {Key key, this.onChanged, this.onConfirm, this.text, this.currentTime})
        : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return ButtonWidget(
        onPressed: () {
          DatePicker.showDatePicker(context,
              theme: DatePickerTheme(
                containerHeight: context.dynamicHeight(0.3),
              ),
              showTitleActions: true,
              minTime: DateTime(2021, 1, 1),
              maxTime: DateTime(2028, 12, 29),
              onChanged: onChanged,
              onConfirm: onConfirm,
              currentTime: currentTime,
              locale: LocaleType.tr);
        },
        text: text,
        buttonColor: Colors.white,
        borderColor: Colors.black,
        textColor: Colors.black,
      );
    }
  }
  </code></pre>