更好的DateTime.Parse在那里? [英] better DateTime.Parse out there?

查看:64
本文介绍了更好的DateTime.Parse在那里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道那里的一个库(收费的或不收费的)能够处理比DateTime.Parse使用的更常见的datetime格式吗?可以在几天/几个月内处理多种语言和缩写的东西真的很棒.

Does anyone know of a library (paid or not) out there that is able to handle more common datetime formats than DateTime.Parse uses? Something that can handle multiple languages and abbreviations for days/months would be really nice.

例如:"2009年9月1日"不适用于Datetime.Parse.

For example: "Sept 1, 2009" does not work with Datetime.Parse.

推荐答案

要使用非标准缩写解析日期,您需要创建自己的文化.

To parse dates with non-standard abbreviations, you'll need to create your own culture.

例如:(已测试)

var culture = new CultureInfo("en-US");
culture.DateTimeFormat.AbbreviatedMonthNames = new string[] { 
    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec", "" 
};

DateTime.Parse("Sept 1, 2009", culture);

这篇关于更好的DateTime.Parse在那里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆