| | |
| | | using System; |
| | | using Microsoft.SqlServer.Server; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Globalization; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | /// <summary> |
| | | /// 转时间 |
| | | /// </summary> |
| | | /// <param name="obj">对象</param> |
| | | /// <param name="format"></param> |
| | | /// <returns>时间</returns> |
| | | public static DateTime? ToDateTime(this object obj, string format) |
| | | { |
| | | if (obj != null && DateTime.TryParseExact(obj.ToString(), format, CultureInfo.InvariantCulture, DateTimeStyles.None, out var date) && date != DateTime.MinValue && date != DateTimeOffset.MinValue) |
| | | { |
| | | return date; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 转时间 |
| | | /// </summary> |
| | | /// <param name="dic">字典</param> |
| | | /// <param name="key">键</param> |
| | | /// <returns>值</returns> |