zoukankan      html  css  js  c++  java
  • 将object类型转换成时间,如果能转的话。

       1:  //将object类型转换成时间,如果能转的话。
       2:  protected DateTime GetDataTime(object obj) 
       3:  { 
       4:      if (obj == null) 
       5:      { 
       6:          return DateTime.Now; 
       7:      } 
       8:      else 
       9:      { 
      10:          DateTime time = DateTime.Now; 
      11:          bool isConvertSeccess = DateTime.TryParse(obj.ToString(), out time); 
      12:          //若是转换成功,time中就是转换的值,若失败,则变成日期初始化值。
      13:          if (isConvertSeccess) 
      14:              return time; 
      15:          else 
      16:              return DateTime.Now; 
      17:      } 
      18:  }
  • 相关阅读:
    基于Twisted的简单聊天室
    小学题的python实现
    初识Go(8)
    初识Go(7)
    初识Go(6)
    初识Go(5)
    初识Go(4)
    初识Go(3)
    初识Go(2)
    初识Go(1)
  • 原文地址:https://www.cnblogs.com/pnljs/p/2959683.html
Copyright © 2011-2022 走看看