K
Kevin Kenny
Dear All,
I have a date time validation method thus:
public static bool IsDate(string date, System.IFormatProvider provider) {
try {
DateTime.Parse(date, provider)
return true;
} catch (System.FormatException)
return false;
}
}
This works a treat from a console app:
e.g. bool b = Utils.IsDate("21/2/2003", new CultureInfo("en-GB"));
However DateTime.Parse throws an exception if the method is called from
ASP.NET.
Upon further inspection of the CultureInfo object's
DateTimeFormat.ShortDatePattern, it reveals itself as "dd/MM/yyyy" when
called from the console app but is set to "M/d/yyyy" when called from an
ASP.NET application.
Anyone got a clue as to whats happening here. Setting the
ShortDatePattern to "dd/MM/yyyy" solved the problem but it is not very
satisfying when supposedly the culture info object ought to be correct
for en-GB.
The environment is XP, VS.NET2002, FW 1.0.3705.288.
Thanks
Kevin
I have a date time validation method thus:
public static bool IsDate(string date, System.IFormatProvider provider) {
try {
DateTime.Parse(date, provider)
return true;
} catch (System.FormatException)
return false;
}
}
This works a treat from a console app:
e.g. bool b = Utils.IsDate("21/2/2003", new CultureInfo("en-GB"));
However DateTime.Parse throws an exception if the method is called from
ASP.NET.
Upon further inspection of the CultureInfo object's
DateTimeFormat.ShortDatePattern, it reveals itself as "dd/MM/yyyy" when
called from the console app but is set to "M/d/yyyy" when called from an
ASP.NET application.
Anyone got a clue as to whats happening here. Setting the
ShortDatePattern to "dd/MM/yyyy" solved the problem but it is not very
satisfying when supposedly the culture info object ought to be correct
for en-GB.
The environment is XP, VS.NET2002, FW 1.0.3705.288.
Thanks
Kevin