Пример #1
0
        /// <summary>
        /// 获取 DateTimeString 的季度
        /// </summary>
        /// <param name="data">yyyy-MM-dd 或 yyyyMM</param>
        /// <returns></returns>
        public static int GetQuarterNumber(string data)
        {
            if (data.Length == 10)
            {
                DateTime date = ConvertObject.ToDateTime(data);
                return(GetQuarterNumber(date));
            }
            else if (data.Length == 6)
            {
                string month = data.Substring(4, 2);
                switch (month)
                {
                case "01":
                case "02":
                case "03":
                    return(1);

                case "04":
                case "05":
                case "06":
                    return(2);

                case "07":
                case "08":
                case "09":
                    return(3);

                case "10":
                case "11":
                case "12":
                    return(4);
                }
            }
            return(0);
        }
Пример #2
0
        /// <summary>
        /// 将 DateTimeString 转换为 ""yyyyMM" 格式 String
        /// </summary>
        /// <param name="dateString"></param>
        /// <returns></returns>
        public static String GetMonthString(string dateString)
        {
            DateTime date = ConvertObject.ToDateTime(dateString);

            return(GetMonthString(date));
        }
Пример #3
0
        /// <summary>
        /// 将 DateTimeString 转换为指定格式 String
        /// </summary>
        /// <param name="dateString"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public static String ToString(string dateString, string format)
        {
            DateTime date = ConvertObject.ToDateTime(dateString);

            return(ToString(date, format));
        }
Пример #4
0
        /// <summary>
        /// 将 DateTimeString 转换为 ""yyyy" 格式 String
        /// </summary>
        /// <param name="dateString"></param>
        /// <returns></returns>
        public static String ToYearString(string dateString)
        {
            DateTime date = ConvertObject.ToDateTime(dateString);

            return(ToYearString(date));
        }
Пример #5
0
        /// <summary>
        /// 获取 DateTimeString 的季度
        /// </summary>
        /// <param name="dateString"></param>
        /// <returns></returns>
        public static int ToQuarterNumber(string dateString)
        {
            DateTime date = ConvertObject.ToDateTime(dateString);

            return(ToQuarterNumber(date));
        }