I have a data from DateTime. with output = "10 October 2014". and I want output like this = "10 Oktober 2014".
This is my test code:
lblTglSuratKeluar.Text = suratKeluarc.TglSurat.ToString("dd MMMM yyyy"); //10 October 2014
var A = lblTglSuratKeluar.Text.Substring(3); //October 2014
var B = A.Substring(0, A.Length - 5); //October
=>So, how to use culturestype ??
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
string testOutPut = string.Join(Environment.NewLine, cultures.Select(c => String.Format("{0}: {1}", B, c.DateTimeFormat.GetMonthName(1))).ToArray());
please, help me...
Thanks...
This is what you should use:
lblTglSuratKeluar.Text = suratKeluarc.TglSurat.ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("id-ID"));
Check out this question.
You should use "id-ID" CultureInfo and parse your string into a DateTime object using the culture info.
// Get the default formatted date
string indonesianDate = suratKeluarc.TglSurat.ToString();
// Parse the date string using the indonesian cultureinfo
System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("id-ID");
DateTime dt = DateTime.Parse(indonesianDate, cultureinfo);
// Get your formatted string.
lblTglSuratKeluar.Text = dt.ToString("dd MMMM yyyy", cultureinfo);
You can find the other culture codes here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With