码迷,mamicode.com
首页 > 其他好文 > 详细

UnixTime的时间戳的转换

时间:2017-11-06 00:43:00      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:sum   res   async   tostring   tpc   tty   text   readline   das   

 public static string XConvertDateTime(double unixTime)
        {
            System.DateTime time = System.DateTime.MinValue;
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            return startTime.AddMilliseconds(unixTime).ToString("yyyy-MM-dd HH:mm:ss");
        }

处理Linux时间戳

 

 public class HttpClientSubmait
    {
        /// <summary>
        /// 异步 post 提交
        /// </summary>
        /// <param name="newJson"></param>
        /// <param name="newUrl"></param>
        /// <returns></returns>
        public static HttpResponseMessage XPostAsJsonAsync(string newJson, string newUrl)
        {
            return new HttpClient().PostAsJsonAsync(newUrl, newJson).Result;
        }

        /// <summary>
        /// 异步get提交
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string XGetAsync(string url)
        {
            return new HttpClient().GetAsync(url).Result.Content.ReadAsStringAsync().Result;
        }

        public static HttpResponseMessage XPutAsJsonAsync(string newJson, string newUrl)
        {
            return new HttpClient().PutAsJsonAsync(newUrl, newJson).Result;
        }

        public static string PostMoths(string url, string param)
        {
            string strURL = url;
            System.Net.HttpWebRequest request;
            request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
            request.Method = "POST";
            request.ContentType = "application/json;charset=UTF-8";
            string paraUrlCoded = param;
            byte[] payload;
            payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
            request.ContentLength = payload.Length;
            Stream writer = request.GetRequestStream();
            writer.Write(payload, 0, payload.Length);
            writer.Close();
            System.Net.HttpWebResponse response;
            response = (System.Net.HttpWebResponse)request.GetResponse();
            System.IO.Stream s;
            s = response.GetResponseStream();
            string StrDate = "";
            string strValue = "";
            StreamReader Reader = new StreamReader(s, Encoding.UTF8);
            while ((StrDate = Reader.ReadLine()) != null)
            {
                strValue += StrDate + "\r\n";
            }
            return strValue;
        }
    }

一步提交的处理事项

UnixTime的时间戳的转换

标签:sum   res   async   tostring   tpc   tty   text   readline   das   

原文地址:http://www.cnblogs.com/yuan-2012/p/7790077.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!