Sometimes We need to convert the Gregorian Date to Islamic Date. We can do this by CultureInfo class of Globalization
Step 1: The markup
Enter Gregorian Date: <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btnCheck" runat="server" Text="Check"
onclick="btnCheck_Click" />
<br />
<asp:label ID="lblDate" runat="server" text=""></asp:label>
Step 2: Write the Following Code on Button Click event.
using System.Globalization;
protected void btnCheck_Click(object sender, EventArgs e)
{
CultureInfo arSA = CultureInfo.CreateSpecificCulture("ar-SA");
string[] arrDt = txtDate.Text.Split('/');
int dd = Convert.ToInt32(arrDt[0]);
int mm = Convert.ToInt32(arrDt[1]);
int yy=Convert.ToInt32(arrDt[2]);
DateTime dt = new DateTime(yy,mm,dd);
string s = dt.ToString("dd/MM/yyyy", arSA);
lblDate.Text = "The Hijri Date is " + s;
}
Output:
Step 1: The markup
Enter Gregorian Date: <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btnCheck" runat="server" Text="Check"
onclick="btnCheck_Click" />
<br />
<asp:label ID="lblDate" runat="server" text=""></asp:label>
Step 2: Write the Following Code on Button Click event.
using System.Globalization;
protected void btnCheck_Click(object sender, EventArgs e)
{
CultureInfo arSA = CultureInfo.CreateSpecificCulture("ar-SA");
string[] arrDt = txtDate.Text.Split('/');
int dd = Convert.ToInt32(arrDt[0]);
int mm = Convert.ToInt32(arrDt[1]);
int yy=Convert.ToInt32(arrDt[2]);
DateTime dt = new DateTime(yy,mm,dd);
string s = dt.ToString("dd/MM/yyyy", arSA);
lblDate.Text = "The Hijri Date is " + s;
}
Output:
No comments:
Post a Comment