博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

和历与西历之间的转换

Posted on 2007-10-24 10:27  懒人ABC  阅读(2767)  评论(1编辑  收藏  举报
//和历转西历
private string DateTimeTransform(string pDate, string pFormat)
        {
            CultureInfo vCurrentInfo = new CultureInfo("ja-JP", true);
            vCurrentInfo.DateTimeFormat.Calendar = new JapaneseCalendar();
            DateTime vCurrentDate = Convert.ToDateTime(pDate, vCurrentInfo.DateTimeFormat);

            string vReturnDate = vCurrentDate.ToString(pFormat, DateTimeFormatInfo.InvariantInfo);

            return vReturnDate;
        }
//西历转和历
private string DateTimeTransform(string pDate, string pFormat)
        {
            CultureInfo vCurrentInfo = new CultureInfo("ja-JP", true);
            vCurrentInfo.DateTimeFormat.Calendar = new JapaneseCalendar();
            DateTime vCurrentDate = Convert.ToDateTime(pDate);

            string vReturnDate = vCurrentDate.ToString(pFormat, vCurrentInfo.DateTimeFormat);

            return vReturnDate;
        }