i have web service on server won't able manage regional settings. web methods need date format "d.m.yyyy", when make call web method , pass date-time string, server should parse string date format "d.m.yyyy" only, date separator "." in desktop application doing following code:
public partial class mainf : form { cultureinfo customculture = new cultureinfo(cultureinfo.currentculture.name); public mainf() { initializecomponent(); customculture.datetimeformat.shortdatepattern = "d.m.yyyy"; customculture.datetimeformat.dateseparator = "."; thread.currentthread.currentculture = customculture; } private void displaydate(string date) { string output=""; datetime mydate; if (!datetime.tryparse(input, customculture, datetimestyles.none, out mydate)) { messagebox.show("date cannot parsed!"); } else { messagebox.show(mydate.toshortdatestring()); } } }
but in webservice should put definition date format,date separator , current thread culture = custom culture??? in every single method or not? sorry not familiar web services now. thank in advance!
if wanna supply custom format, need use datetime.tryparseexact
method instead of datetime.tryparse
. example;
if(datetime.tryparseexact(input, customculture.datetimeformat.shortdatepattern, customculture, datetimestyles.none, out mydate)) { messagebox.show("date cannot parsed!"); }
exact
difference between these 2 methods points custom format.
by way, don't see any input
in code variable maybe might mixing date
or output
variables..
Comments
Post a Comment