c# - 将“ספטמבר 15, 2018 בשעה 10:20 am”转换为日期时间 C#
问题描述
我有一个 REST api,它以字符串形式存储日期时间:“ספטמבר 15, 2018 בשעה 10:20 am” 以上包括系统语言(在本例中为希伯来语)。有什么方法可以将其转换为 C# DateTime
解决方案
我会将所有希伯来文本转换为英文文本,然后将合适的格式字符串传递给 DateTime.TryParseExact
例如
string dateInEnglish = dateInHebrew.Replace("ספטמבר", "September"). Replace("בשעה","")
会从那个日期去掉所有的希伯来语,尽管在实践中我会使用正则表达式。
查看 TryParseExact 上的文档以创建合适的格式字符串:
推荐阅读
- python - pip install 从哪里获取软件包?
- javascript - 以角度调整速度运动动态
- python-3.x - 用于基于子关系和父关系添加新行和列的 Python 代码逻辑
- android - React Native Android azure build 随机失败
- c# - Wix:是否可以从卸载 UI (C#) 中删除/禁用取消按钮?
- swift - 是否可以快速将要发送到特定whatsapp号码的图像深度链接
- javascript - 正则表达式在多行文本中查找多个字符串模式
- python - pandas 系列:用插值数据点删除和替换 NaN
- java - 有什么想法可以防止特定属性出现在日志中吗?
- r - Talend 中的 R 脚本