formatDateTime method

String formatDateTime()

Implementation

String formatDateTime() {
  DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(this);
  DateTime now = DateTime.now();
  String format = 'HH:mm';
  if (dateTime.year != now.year) {
    format = 'yyyy-MM-dd HH:mm';
  } else if (dateTime.day != now.day) {
    format = 'MM-dd HH:mm';
  }
  return DateFormat(format).format(dateTime);
}