/// <summary>
/// OctetString转时间
/// </summary>
/// <param name="ss">字符串如 07 E3 06 06 11 10 0A 00 2B 08 00</param>
/// <returns>2012-09-23 17:01:27</returns>
public static string OctetString2DateAndTime(string ss)
{
// 07 E3 06 06 11 10 0A 00 2B 08 00
byte[] bts=ss.Trim().Split(' ').Select(s => byte.Parse(Convert.ToInt32("0x" + s, ).ToString())).ToArray();
byte[] format_str = new byte[]; //保存格式化过后的时间字符串
int year = bts[] * + bts[];
int month = bts[];
int day = bts[];
int hour = bts[];
int minute = bts[];
int second = bts[];
int msecond = bts[];
//以下为格式化字符串
int index = ;
int temp = year;
for (; index >= ; index--)
{
format_str[index] = (byte)( + (temp - temp / * ));
temp /= ;
} format_str[] = (byte)'-';
index = ;
temp = month;
for (; index >= ; index--)
{
format_str[index] = (byte)( + (temp - temp / * ));
temp /= ;
} format_str[] = (byte)'-';
index = ;
temp = day;
for (; index >= ; index--)
{
format_str[index] = (byte)( + (temp - temp / * ));
temp /= ;
} format_str[] = (byte)' ';
index = ;
temp = hour;
for (; index >= ; index--)
{
format_str[index] = (byte)( + (temp - temp / * ));
temp /= ;
} format_str[] = (byte)':';
index = ;
temp = minute;
for (; index >= ; index--)
{
format_str[index] = (byte)( + (temp - temp / * ));
temp /= ;
} format_str[] = (byte)':';
index = ;
temp = second;
for (; index >= ; index--)
{
format_str[index] = (byte)( + (temp - temp / * ));
temp /= ;
}
return Encoding.Default.GetString(format_str);
}

最新文章

  1. thinkphp 设计思想
  2. iOS ARC和MRC混编
  3. Java中获取完整的url
  4. php 燕十八 观察者模式代码例子
  5. 修改上一篇文章的node.js代码,支持默认页及支持中文
  6. JS 部分常见循环、分支、嵌套练习
  7. 用C语言实现Ping程序功能
  8. Oracle实验手册
  9. 【代码审计】五指CMS_v4.1.0 copyfrom.php 页面存在SQL注入漏洞分析
  10. cocos2dx 粒子系统
  11. nginx 执行理解
  12. 【Python】读取excel数据
  13. Docker一键部署Hadoop心得(一)
  14. iKcamp|基于Koa2搭建Node.js实战(含视频)☞ 视图Nunjucks
  15. Linux 设备模型之 (kobject、kset 和 Subsystem)(二)
  16. 【BZOJ4922】[Lydsy六月月赛]Karp-de-Chant Number 贪心+动态规划
  17. 中国大学MOOC-JAVA学习(浙大翁恺)—— 温度转换
  18. swoole http_server 多进程并使用多进程处理消息
  19. 【BZOJ5329】【SDOI2018】战略游戏(圆方树,虚树)
  20. 1.ubuntu的安装

热门文章

  1. Codes: MODERN ROBOTICS Ch.3_Expo. Coods.基础代码实现
  2. Systemweaver — 电子电气协同设计研发平台
  3. C++中与类有关的注意事项(更新中~~~)
  4. 《基于 Java EE 的高校重修管理系统设计与实现》论文笔记(九)
  5. 忘记 MySQL 的 root 帐号密码该怎么办
  6. 行为型模式(四) 观察者模式(Observer)
  7. docker 进程 转载:
  8. navcat导入mysql.sql出现:2006, &#39;MySQL server has gone away&#39;
  9. am335x system upgrade kernel can(八)
  10. Windows异常的分发处理流程