加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 转换JSON日期时间2017-03-19T23:54:46至2017年3月19日11

发布时间:2020-12-15 22:49:23 所属栏目:百科 来源:网络整理
导读:如何在SSIS的脚本C#脚本中执行此操作.当前日期时间是来自 JSON列的字符串.我正在尝试执行此操作 DateTime convertedDate = DateTime.Parse(dateString); 但错误说CreationTime不在当前上下文中.我在所有部分中尝试过 public override void Input0_ProcessInp
如何在SSIS的脚本C#脚本中执行此操作.当前日期时间是来自 JSON列的字符串.我正在尝试执行此操作

DateTime convertedDate = DateTime.Parse(dateString);

但错误说CreationTime不在当前上下文中.我在所有部分中尝试过

public override void Input0_ProcessInputRow(Input0Buffer Row)

public override void PostExecute()

但仍然得到相同的错误.

解决方法

尝试使用DateTime.ParseExact()函数

CultureInfo provider = CultureInfo.InvariantCulture;
DateTime convertedDate = DateTime.ParseExact(dateString,"yyyy-MM-ddTHH:mm:ss",provider);

如果需要将其作为String返回,格式如下:MM / dd / yyyy hh:mm:ss tt你可以使用ToString()函数

String strDate = convertedDate.ToString("MM/dd/yyyy hh:mm:ss tt");

参考

> DateTime.ParseExact Method (String,?String,?IFormatProvider)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读