using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DSWeb.Common { /// /// long数据拓展 /// public static class LongExtension { /// /// 将毫秒时间戳转换为普通时间 /// /// 毫秒级别的时间戳 /// public static DateTime ToDateTimeMilliseconds(this long timestamp) { System.DateTime time = System.DateTime.MinValue; DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0); time = startTime.AddMilliseconds(timestamp).Add(TimeZoneInfo.Local.BaseUtcOffset); return time; } /// /// 将秒级别时间戳转换为普通时间 /// /// 秒级别的时间戳 /// public static DateTime ToDateTimeSecoders(this long timestamp) { DateTime time = System.DateTime.MinValue; DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0); time = startTime.AddSeconds(timestamp).Add(TimeZoneInfo.Local.BaseUtcOffset); return time; } /// /// 讲标准时间戳(秒级)转换为时间格式 /// /// /// public static DateTime ToDataTime(this long timestamp) { return ToDateTimeSecoders(timestamp); } } }