UnixTime的時間戳的轉換

 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時間戳json

 

 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;
        }
    }

一步提交的處理事項app

相關文章
相關標籤/搜索