日期时间解析抛出hh vs hh异常

本文关键字:hh vs 异常 时间 日期 | 更新日期: 2023-09-27 18:19:14

contacthours.Hours1Fromcontacthours.Hours1To抛出异常。hh和hh有区别吗?

ExtendedContactDetailsType contactdetails = new ExtendedContactDetailsType();
contactdetails.ClassifiedAdContactByEmailEnabled = true;
ContactHoursDetailsType contacthours = new ContactHoursDetailsType();
contacthours.Hours1AnyTime = false;
contacthours.Hours1Days = DaysCodeType.Weekdays;
contacthours.Hours1From = DateTime.ParseExact("08:00", "hh:mm", null);
contacthours.Hours1To = DateTime.ParseExact("16:00", "hh:mm", null);
contacthours.TimeZoneID = "Eastern";
contactdetails.ContactHoursDetails = contacthours;
item.ExtendedSellerContactDetails = contactdetails;

日期时间解析抛出hh vs hh异常

第一个问题是您没有使用24小时格式字符串:

contacthours.Hours1From = DateTime.ParseExact("08:00", "HH:mm", null);
contacthours.Hours1To = DateTime.ParseExact("16:00", "HH:mm", null);

这是否是only的问题尚不清楚。