Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Datetime problem
Message
 
 
To
All
General information
Forum:
C#
Category:
Coding, syntax and commands
Title:
Datetime problem
Miscellaneous
Thread ID:
01652147
Message ID:
01652147
Views:
63
Hi everybody,

This line of code is failing for one client

parameter.Value = Convert.ToDateTime(parameterValue);

but works fine for me.

The value is "06/21/2017 11:30:56".

I suspect (and it's very likely) that this client's locale is Spanish, so the date would not be properly recognized.

The question is - how should I adjust the code above? I assume that the date will always come in US locale, but I can not guarantee this 100% for sure. I also can not demand that the calling application will send the date in ISO format.

So, what is the best solution here?

Thanks in advance.

Found suggestion to use

Convert.ToDateTime(parameterValue, new CultureInfo("en-US"))

so, I'll try that.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform