Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Datetime problem
Message
 
 
À
Tous
Information générale
Forum:
C#
Catégorie:
Code, syntaxe and commandes
Titre:
Datetime problem
Divers
Thread ID:
01652147
Message ID:
01652147
Vues:
64
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform