日期格式设置

public static DateTime Str2Date(string value) { if (string.IsNullOrEmpty(value)) return DateTime.MinValue; else { DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "dd-MM-yy"; return Convert.ToDateTime(value, dtFormat); } } public static string Date2String(DateTime value) { if (value == DateTime.MinValue) return string.Empty; else return value.ToString("dd-MM-yy"); }
posted @ 2013-01-10 10:30  717806198  阅读(175)  评论(0编辑  收藏  举报