/// /// Convert to DateTimeOffset from Json Date(Unix epoch) /// /// ex: "/Date(1324707957994+0900)/" /// public Nullable ConvertToDateTimeOffsetFromJsonDate(string jsondate) { if (String.IsNullOrEmpty(jsondate)) return null; Regex regex = new System.Text.RegularExpressions.Regex(@"^\/date\((\d*)([\+\-]?\d*)\)\/+$"); MatchCollection matchCol = regex.Matches(jsondate.ToLower()); if (matchCol.Count == 0) throw new InvalidArgumentException("No match."); Int64 ticks = Int64.Parse(matchCol[0].Groups[1].ToString()); string stroffset = matchCol[0].Groups[2].ToString(); DateTimeOffset offset; DateTimeOffset.TryParseExact(stroffset, "zzz", System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None, out offset); return new DateTimeOffset(new System.DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(ticks).Add(offset.Offset), offset.Offset); }