从回历转换为ASP&放格鲁吉亚日期; C#? [英] Convert From Hijri to Georgian date in ASP & C#?

查看:129
本文介绍了从回历转换为ASP&放格鲁吉亚日期; C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框,在其中的回历日期这我在这个文本框中使用日历扩展插入日期。我想的是,在日(回历日期)的选择,格鲁吉亚文本框将使用C#充满转换格鲁吉亚日期。

I have two text boxes, One in Hijri Date which I am inserting date in this text box using the calender extender. What I want is that upon selection of date (Hijri Date), the Georgian text box will filled with converted Georgian date using C#.

有没有人有code更改回历日期格鲁吉亚日期?

Does anyone has code for changing the hijri date to georgian date?

推荐答案

您可以简单地回历之间转换公历使用内置的CultureInfo类

You can simply convert between Hijri and Gregorian using the built in CultureInfo class

Imports System.Globalization

Private Sub Convert_From_Hijri_To_Gregorian(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim arCI As CultureInfo = New CultureInfo("ar-SA")
    Dim hijri As String = Me.TextBox1.Text   '//check if string is valid date first

    Dim tempDate As DateTime = DateTime.ParseExact(hijri, "dd/MM/yyyy", arCI.DateTimeFormat, DateTimeStyles.AllowInnerWhite)
    Me.TextBox2.Text = tempDate.ToString("dd/MM/yyyy")

End Sub

我不是一个C#的家伙,但这里是我上面code到C#

I am not a C# guy but here is my the conversion of the above code to C#

using System.Globalization;

private void Convert_From_Hijri_To_Gregorian(System.Object sender, System.EventArgs e)
{
    CultureInfo arCI = new CultureInfo("ar-SA");
    string hijri = TextBox1.Text;

    DateTime tempDate = DateTime.ParseExact(hijri, "dd/MM/yyyy", arCI.DateTimeFormat, DateTimeStyles.AllowInnerWhite);
    TextBox2.Text = tempDate.ToString("dd/MM/yyyy");


}

我已经读<后写了这code href=\"http://www.$c$cproject.com/Articles/8838/Convert-date-from-Hijri-Calendar-to-Gregorian-Cale\">this文章

这篇关于从回历转换为ASP&放格鲁吉亚日期; C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆