日期:2014-05-18 浏览次数:21392 次
static void Main(string[] args)
{
DateTime dt = fsshijian("2170020102");
Console.WriteLine(dt);
string s = "4F60597D597D8FD80020521A521A597D597D597D5E724E56";
byte[] b = new byte[24];
for (int i = 0; i < 24; i++)
b[i] = Convert.ToByte(s.Substring(i * 2, 2), 16);
string mmsg = Encoding.BigEndianUnicode.GetString(b);
Console.WriteLine(mmsg);
Console.ReadLine();
}
static DateTime fsshijian(string sj)
{
DateTime dt = new DateTime();
if (sj.Length == 10)
{
char* ca = stackalloc char[16];
ca[0] = '2';
ca[1] = '0';
ca[2] = sj[1];
ca[3] = sj[0];
ca[4] = '/';
ca[5] = sj[3];
ca[6] = sj[2];
ca[7] = '/';
ca[8] = sj[5];
ca[9] = sj[4];
ca[10] = ' ';
ca[11] = sj[7];
ca[12] = sj[6];
ca[13] = ':';
ca[14] = sj[9];
ca[15] = sj[8];
DateTime.TryParse(new string(ca, 0, 16), out dt);
}
return dt;
}