I am trying to convert date in different format. I am facing difficulties for Bulgarian format. When I am taking shortdate format and long time format it is giving two symbols in single quotes. But when I am trying to convert it directly to string using tostring or convert.tostring in the generated string it is removing single quote.
Now I want specific format to display on UI, that is ShortDatePattern + " " + LongTimePattern. So, for UI I am passing this to Jquery.Globalized library and it is returning date with single quote.
Now, first question is which format is correct? with or without single quote? And second question is if one is correct why there are two I am getting, mean what I am doing wrong in either of the case?
Here is code snippet.
CultureInfo ci = new CultureInfo ("bg-BG");
var dateFormat = ci.DateTimeFormat.ShortDatePattern; //"d.M.yyyy 'г.'"
var timeFormat = ci.DateTimeFormat.LongTimePattern; //"HH:mm:ss 'ч.'"
var somedate = DateTime.Parse("01/01/2001");
var somedateInString = somedate.ToString(new CultureInfo("bg-BG")); //1.1.2001 г. 00:00:00 ч.
var somedataInString2 = Convert.ToString (somedate, new CultureInfo ("bg-BG")); //1.1.2001 г. 00:00:00 ч.
Please let me know if more details required.
.Net's custom date time format strings syntax designates text within quotes (single or double) as literal text. You will need to translate between the syntax of .Net's custom date time format strings and that of the Jquery.Globalized library.