Hi All,
I am trying to convert the Date fields in CRM to Arabic and store it in a text field. I have Successfully split the day, month and year into individual string variables but when i try to concatenate it, i am not getting the desired format as DD-MMM-YYYY instead my output is DYYYY-MMM-D.
SEE like this ۱٤-فبراير-۲٠۱٩
See my below code:
using System;
using System.Globalization;
using System.Text;
using System.Collections;
public static class Program
{
public static void Main()
{
string year = DateTime.Now.Year.ToString();
year = ConvertNumeralsToArabic(year);
string arabicDate = ConvertDateToArabic(Convert.ToDateTime(DateTime.Now.Date.AddDays(1)));
string a = ConvertNumeralsToArabic(arabicDate);
StringBuilder builder = new StringBuilder(arabicDate);
builder.Replace("YYYY", year);
string d = builder.ToString();
d = ConvertNumeralsToArabic(d);
string data = d;
char[] delimiters = new char[] { '-' };
string[] parts = data.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
ArrayList arr = new ArrayList();
for (int i = 0; i < parts.Length; i++)
{
arr.Add(parts[i]);
}
string day = arr[0].ToString();
string month = arr[1].ToString();
string year1 = arr[2].ToString();
string test = day + "-" + month + "-" + year;
Console.WriteLine(day);
Console.WriteLine(month);
Console.WriteLine(year1);
Console.WriteLine(test);
}
public static string ConvertDateToArabic(DateTime date)
{
return date.ToString("dd-MMM-YYYY", CultureInfo.GetCultureInfo("ar-ae"));
}
public static string ConvertNumeralsToArabic(string input)
{
return input = input.Replace('0', '٠').Replace('1', '۱').Replace('2', '۲').Replace('3', '۳').Replace('4', '٤').Replace('5', '۵')
.Replace('6', '٦')
.Replace('7', '٧')
.Replace('8', '٨')
.Replace('9', '٩');
}
}
Appreciate your help here.
Regards,
AKHIL
*This post is locked for comments