using System; using System.Collections.Generic; using System.Text; namespace 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 ToDateTime(this long timestamp) { return ToDataTime(timestamp); } /// /// 将标准时间戳(秒级)转换为时间格式 /// /// /// public static DateTime ToDataTime(this long timestamp) { return ToDateTimeSecoders(timestamp); } } }