Arabic Calendar Date to English Calendar Date in Windows Form C#

Here you see how to change Arabic Calendar Date to English Calendar Date in Windows Form C#.

Step 1: Go to the VS 2010 Menu and select "File" -> "New" -> "Project.." then select Visual C# -> Window Forms Application and create the Windows Forms application.


Figure 1

Step 2: Then we will select the make Form Fig 2 using Textbox, Label, Button figure 2


Figure 2

Step 3: Then go to the Form 1 file and write this code to convert to Arabic date to English date.Double click BUTTON write this code
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Windows.Forms;  
  9. using System.Threading;  
  10. using System.Globalization;  
  11. namespace WindowsFormsApplication1  
  12. {  
  13.    public partial class Form1 : Form  
  14.    {  
  15.       public Form1()  
  16.       {  
  17.           InitializeComponent();  
  18.       }  
  19.       private void button1_Click(object sender, EventArgs e)  
  20.       {  
  21.          CultureInfo arCI = new CultureInfo("ar-SA");  
  22.          string hijri = textBox1.Text + " 00:00:00";  
  23.          //txtenglishDate.Text = tempDate.ToString("dd/MM/yyyy");DateTime tempDate = DateTime.ParseExact(hijri, "         dd/MM/yyyy hh:mm:ss", arCI.DateTimeFormat, DateTimeStyles.AllowInnerWhite);  
  24.          string ar = tempDate.ToString(new CultureInfo("ar-SA"));  
  25.          GregorianCalendar enCalendar = new GregorianCalendar();  
  26.          int year = enCalendar.GetYear(tempDate);  
  27.          int month = enCalendar.GetMonth(tempDate);  
  28.          int day = enCalendar.GetDayOfMonth(tempDate);  
  29.          textBox2.Text = (string.Format("{0}/{1}/{2}", day, month, year));  
  30.       }  
  31.    }  
  32. }  

Figure 3


Step 4: Then we will Enter the valid arabic date (hijiri date) in the format of "DD/MM/YYYY" if u want change the format u can include format also.


Figure 4

Output


Figure 5

Summary

In this article, we discussed discuss how to convert arabic date to english date in Windows Forms. After that, we discussed how to use its various properties and methods to build real gulf world applications.

 

Ebook Download
View all
Learn
View all