Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Arabic Conversion of Date fields using plugin.

(0) ShareShare
ReportReport
Posted on by 432

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

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Arabic Conversion of Date fields using plugin.

    Great :)

  • Verified answer
    Akhil101 Profile Picture
    Akhil101 432 on at
    RE: Arabic Conversion of Date fields using plugin.

    I got the solution ravi. Hurrayyyyyy :) :)

    its like you need to use Right to Left while concatenating the string variables!!!!!!!!!!!!

    Below is the code:

    public static string ConcatBidirectionalWithJoin()

    {

    string IdWithSubType = "طائرات هليكوبت";

    string MiddleString = "(100252575";

    string EndString = "@vk.com";

    string ltr = ((char)0x200E).ToString();

    return string.Join(ltr, IdWithSubType, MiddleString, EndString);

    }

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Arabic Conversion of Date fields using plugin.

    I tried it again and it turns out that be defaykt when you are adding the MMM (i.e. month name), it is putting the month name at last even if you concatenate dd-MMM-yyyy.

    It works fine with the number- ConvertNumeralsToArabic(DateTime.Today.ToString("dd-MM-yyy",new CultureInfo("ar-ae")))

  • Akhil101 Profile Picture
    Akhil101 432 on at
    RE: Arabic Conversion of Date fields using plugin.

    Hi Ravi,

    Thanks for your response!

    I tried with that but i am getting the result as dd-YYYY-MMM but i want the result as DD-MMM-YYYY. This is the reason i split the day, month and year into different string variables then tried to concatenate it still not getting the desired result.

    Regards,

    Akhil

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Arabic Conversion of Date fields using plugin.

    Hi,

    Have you tried this-stackoverflow.com/.../how-to-convert-english-date-to-arabic-date-in-net

    DateTime.Now.ToString("dd dddd , MMMM, yyyy", new CultureInfo("ar-AE"));

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans