I am trying to change the DateSeparator and it doesn't work for all cultures. Below, I'm trying to format a date in the Japanese and Korean Cultures and use an underscore for the date separator. It works as expected for Japan, but not for Korea. I've found some other cultures that behave this way as well.
CultureInfo jpCulture = CultureInfo.CreateSpecificCulture("jp");
DateTimeFormatInfo jpFormat = jpCulture.DateTimeFormat;
jpFormat.DateSeparator = "_";
CultureInfo koCulture = CultureInfo.CreateSpecificCulture("ko");
DateTimeFormatInfo koFormat = koCulture.DateTimeFormat;
koFormat.DateSeparator = "_";
string jpDate = DateTime.Now.ToString("d", jpFormat);
string koDate = DateTime.Now.ToString("d", koFormat);
System.Console.WriteLine($"My local (US) formatting: {DateTime.Now:d} - JP Formatter: {jpDate} - KO Formatter: {koDate}");
Will output:
My local (US) formatting: 8/3/2020 - JP Formatter: 08_03_2020 - KO Formatter: 2020-08-03
I had expected the Korean formatted string to use underscores as well.
My goal is to always have a Date format that's appropriate for the culture (YMD, or MDY or DMY) but using a customizable separator. Is there a more appropriate way to do that?