////// 时间戳转成时间类型 /// /// ///public static DateTime GetTime(string timeStamp) { DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); long lTime = long.Parse(timeStamp + "0000000"); TimeSpan toNow = new TimeSpan(lTime); return dtStart.Add(toNow); } /// /// 时间类型转成long /// /// ///public static long ConvertDateTimeInt(System.DateTime time) { long intResult = 0; System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); intResult = (long)(time - startTime).TotalSeconds; return intResult; }
////// 拼接json的字符串; /// 比如:"{\"ret\":\"err\",\"stadname\":\"未知\"}" /// /// ///public static string getJsonStr(Dictionary jsonDict) { StringBuilder sb = new StringBuilder("{"); int i = 0; foreach (KeyValuePair jd in jsonDict) { if (i != (jsonDict.Count() - 1)) { sb.Append("\"" + jd.Key + "\":\"" + jd.Value + "\","); } else { sb.Append("\"" + jd.Key + "\":\"" + jd.Value + "\""); } i++; } sb.Append("}"); return sb.ToString(); }