我在将剑道时间选择器的值保存为 24 小时格式时遇到问题,时间选择器显示"HH:mm tt"
格式但我想将其转换为"HH:mm:ss"
,我使用时间跨度作为我的下拉列表
示例代码
String clientShiftId = formCollection["clientShiftId"];
String clientId = formCollection["clientId"];
String dateShift = formCollection["dllShiftDay"];
String startTime = formCollection["txtStartTime"];
String endTime = formCollection["txtEndTime"];
var stayHere = formCollection["stayHere"];
Client_Customer_Position_Shift clientCusPosShift = new Client_Customer_Position_Shift();
try
{
if (String.IsNullOrWhiteSpace(clientShiftId) || clientShiftId == "0")
{
client.Client_Customer_PositionID = Convert.ToInt32(clientId);
clientCusPosShift.Day_LookID = Convert.ToInt32(dateShift);
DateTime parsed = DateTime.ParseExact(endTime.Trim(), "hh:mm tt",CultureInfo.InvariantCulture);
client.EndTime = parsed.ToString("HH:mm:ss", CultureInfo.InvariantCulture); <------- Line of Error
DateTime parse = DateTime.ParseExact(startTime.Trim(), "hh:mm tt",CultureInfo.InvariantCulture);
client.StartTime = parse.ToString("HH:mm:ss", CultureInfo.InvariantCulture); <------- Line of Error