VB.NET getting date format from date
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.
精彩评论