求教高手了:
1124  
这是一个字符串,我想将其格式化为11:24:00的时间格式(注意,格式化后仍为字符串),因为这样的数据可能会有很多很多,有没有一种有效率一点的方法可以将其格式化出来(秒数这里都为00,还要插入两个冒号)。高手们,请指教了。。

解决方案 »

  1.   

     string a = "1124";
            string b = a.Substring(0,2)+":"+a.Substring(2,2)+":"+"00";
            string c = Convert.ToDateTime(b).ToString("HH:mm:ss") ;
            Response.Write(c);
      

  2.   

    Console.WriteLine(Regex.Replace("1124", @"(\d{2})(\d{2})", "$1:$2:00"));
      

  3.   

    string strTime = "1124";
    string result = DateTime.ParseExact(strTime, "HHmm", DateTimeFormatInfo.CurrentInfo).ToString(HH:mm:ss);
      

  4.   

    不好意思,漏了个引号
    string strTime = "1124";
    string result = DateTime.ParseExact(strTime, "HHmm", DateTimeFormatInfo.CurrentInfo).ToString("HH:mm:ss");