using System.Collections.Generic; namespace Bowin.Web.Controls.Mvc { public class FormatterHelper { protected static Dictionary DictFormatter = new Dictionary(); protected static string DefaultFormatter = ""; protected static List DateFormatterList = new List(); static FormatterHelper() { DictFormatter.Add(Formatter.None, ""); DictFormatter.Add(Formatter.FullDate, "yyyy-MM-dd HH:mm:ss.S"); DictFormatter.Add(Formatter.ShortDate, "hh:mm:ss"); DictFormatter.Add(Formatter.LongDate, "yyyy-MM-dd HH:mm:ss"); DictFormatter.Add(Formatter.OnlyYearMonth, "yyyy-MM"); DictFormatter.Add(Formatter.OnlyYearMonthDay, "yyyy-MM-dd"); DictFormatter.Add(Formatter.CHSShortDate, "hh时mm分ss秒"); DictFormatter.Add(Formatter.CHSLongDate, "yyyy年MM月dd日 HH时mm分ss秒"); DictFormatter.Add(Formatter.CHSLongDateNoSecond, "yyyy年MM月dd日 HH时mm分"); DictFormatter.Add(Formatter.CHSOnlyYearMonthDay, "yyyy年MM月dd日"); DateFormatterList.Add(Formatter.FullDate); DateFormatterList.Add(Formatter.ShortDate); DateFormatterList.Add(Formatter.LongDate); DateFormatterList.Add(Formatter.OnlyYearMonth); DateFormatterList.Add(Formatter.OnlyYearMonthDay); DateFormatterList.Add(Formatter.CHSShortDate); DateFormatterList.Add(Formatter.CHSLongDate); DateFormatterList.Add(Formatter.CHSOnlyYearMonthDay); } public static string GetFormatterString(Formatter formatter) { if (DictFormatter.ContainsKey(formatter)) { return DictFormatter[formatter]; } else { return DefaultFormatter; } } public static Helper.FormatterType GetFormatterType(Formatter formatter) { if (DateFormatterList.Contains(formatter)) return Helper.FormatterType.DateTime; return Helper.FormatterType.None; } } }