开发者

VB.NET getting date format from date

开发者 https://www.devze.com 2023-02-13 16:33 出处:网络
I need to extract the dateformat from a given date. Ho开发者_JAVA技巧w am I suppose to do that. Please help.Most of dates are built like this:

I need to extract the dateformat from a given date. Ho开发者_JAVA技巧w am I suppose to do that. Please help.


Most of dates are built like this:

xsysz 

Where s is a separator that can be '/', '.', ' ' or even ''. x, y and z are digits. The problem is that you cannot solve the date format for every possible date because of its ambiguity:

Example: 3-2-2010 

Germany: 3rd February 2010
USA: 2nd March 2010

You need additional information (is there any separator?) or some preconditions (year-month-day or year-day-month?) in order to be able to do that. (Same for time... of course)

If you have this preconditions, so you might try with regular expressions. DateTime isn't able to do that for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号