DateTimeToXSDateTime static method

String DateTimeToXSDateTime(
  1. DateTime dateTime
)
Dates the DateTime into an XML schema date time. The date time.

Implementation

static String DateTimeToXSDateTime(DateTime dateTime) {
  // TODO : fix DateTimeToXSDateTime
  print(".. used incorret DateTimeToXSDateTime");

  String format = "yyyy-MM-ddTHH:mm:ss";
  var formatter = DateFormat(format);
  final value = formatter.format(dateTime);
  if (dateTime.isUtc) {
    return "${value}Z";
  } else {
    return value;
  }

  //            switch (dateTime.Kind)
  //            {
  //                case DateTimeKind.Utc:
  //                    format += "Z";
  //                    break;
  //                case DateTimeKind.Local:
  //                    format += "zzz";
  //                    break;
  //                default:
  //                    break;
  //            }
  //
  //            // Depending on the current culture, DateTime formatter will replace ':' with
  //            // the DateTimeFormatInfo.TimeSeparator property which may not be ':'. Force the proper string
  //
  //            return dateTime.ToString(format, CultureInfo.InvariantCulture);
}