T
Terry Olsen
I'm a bit confused on how to make my app work in all cultures, particularly
with parsing the date out of a string. I read dates from different web
sites. The formats I've run into include 'yyyy.mm.dd', 'dd/mm/yyyy',
'yyyy-mm-dd', 'dd-mmm-yyyy'.
I'm using the following code to parse the date, which has worked for a lot
of Regions but not all, such as Germany.
Dim CI As System.Globalization.CultureInfo
CI = System.Globalization.CultureInfo.GetCultureInfo("en-US")
Dim dt as String = <Date scraped from web page>
dt = Date.Parse(dt.Trim, CI.DateTimeFormat).ToShortDateString
When the Region is set to Germany, the Date.Parse line throws an exception.
The Message is "String was not recognized as a valid DateTime." In this
case, dt = "2007.03.03"
How can I make this code to produce a valid date string in any culture?
Thanks.
with parsing the date out of a string. I read dates from different web
sites. The formats I've run into include 'yyyy.mm.dd', 'dd/mm/yyyy',
'yyyy-mm-dd', 'dd-mmm-yyyy'.
I'm using the following code to parse the date, which has worked for a lot
of Regions but not all, such as Germany.
Dim CI As System.Globalization.CultureInfo
CI = System.Globalization.CultureInfo.GetCultureInfo("en-US")
Dim dt as String = <Date scraped from web page>
dt = Date.Parse(dt.Trim, CI.DateTimeFormat).ToShortDateString
When the Region is set to Germany, the Date.Parse line throws an exception.
The Message is "String was not recognized as a valid DateTime." In this
case, dt = "2007.03.03"
How can I make this code to produce a valid date string in any culture?
Thanks.