日期:2014-05-19  浏览次数:20775 次

关于string.format如何格式日期
我想把   "20070621153214 "格式化为 "2007-06-21   15:32:14 ",请问string.format能做到吗,要怎么做呢?

------解决方案--------------------
private static string FormatAsDate(string input)
{
StringBuilder sb = new StringBuilder(input);
int index = sb.Length - 2;
sb.Insert(index, ": ");
index -=2;
sb.Insert(index, ": ");
index-=2;
sb.Insert(index, " ");
index -= 2;
sb.Insert(index, "- ");
index -= 2;
sb.Insert(index, "- ");
return sb.ToString();
}