I need to convert strings into datetime objects which are in non-English languages. I have used several languages in other languages. I have seen many examples of changing, but not in other ways.
It does not seem to work:
CultureInfo Provider = New CultureInfo ("AR-AE"); // Arabic - United Arab Emirates string sample = "ا٠?? ØØØØ ØØØØØØØØ ¡16 Ù? Ø§Ø ± س 2011"; Gregorian calendar date / time result / Arabic date; Date time required = new date time (2011, 3, 16); // Expected date bool b; B = DateTime Trypers (sample, provider, datetime style. Non, outcome); Assert.IsTrue (b); Assurance Uncertain (expected, result); In addition, I have to handle those stars which are in other calendars. This is what I tried to do and it does not seem to work either. CultureInfo Provider = New CultureInfo ("AR-AE"); // Arabic - United Arab Emirates provider. Datetime format. Calendars = new system Globalization. Hierarchy calendar (); // Wednesday, March 16, 2011, 11 in Rabi 1432 string sample = "A" ??? 11 Ø ± nancy? ع Ø «Ø§Ù ?? Ù? 1432 "; Date Time Result; Date Time Expected = New Date Time (2011, 3, 16); // Bull B; B = DateTimeTrippers (sample, provider, datetime style.No, outcome result); Assert.IsTrue (B); assurance. Uncertain (expected, result); What am I missing?
If you know the correct format, you can try TryParseExact : b = DateTime.TryParseExact (sample," dddd D MMMM yyyy ", The provider, with its datetime style, forcefully However, in your case, it does not work To find out the problem, try another round: < Code> console WrightLine (expected toaster ("dddd d MMMM yyyy", provider)); And the result is "ا٠?? Ø £ ØØØØØØØØ ¡16 Ù ?? Ø§Ø ± س 2011 "????, which is different from your input in an input (you can probably better read me): .NET Usage (and hopefully) cholera, do not have it in your input if we do this If you modify the input by the way, then everything works:
CultureInfo Provider = New CultureInfo ("AR-AE"); // Arabic - United Arab Emirates String Sample = "Ø §Ù ?? Ø £ ØØØØØØØØØØ¡ ± 16 Ù ?? Ø§Ø ± س 2011 "; Gregorian Calendar Date / Time Result / Arab Date; Date Time Expected = New Date Time (2011, 3, 16); // Expected Date bool; B = DateTime: Trips (sample, Assert.IsTrue (b); assurance; uncertain (expected, result);
Comments
Post a Comment