I use these codes to convert the Gregorian calendar to the Julian calendar, and no problem.
private void button1_Click(object sender, EventArgs e) { JulianCalendar juli = new JulianCalendar(); DateTime dt = Convert.ToDateTime(textBox1.Text); int day = juli.GetDayOfMonth(dt); int month = juli.GetMonth(dt); int year = juli.GetYear(dt); string s = string.Format("{0}/{1}/{2}", month, day, year); textBox2.Text = s; }
This gives me Julian time, but when I want to convert it again to the Gregorian calendar, just at that time, it won't work. I use these following codes to convert the Julian calendar to the Gregorian calendar. what is the problem?
private void button2_Click(object sender, EventArgs e) { string juli = textBox3.Text; string[] parts = juli.Split('/', '-'); JulianCalendar jul = new JulianCalendar(); DateTime dta = jul.ToDateTime(Convert.ToInt32(parts[0]), Convert.ToInt32(parts[1]), Convert.ToInt32(parts[2]), 0, 0, 0, 0); string sta = dta.ToShortDateString(); textBox4.Text = sta; }
c # winforms
aliboy38
source share