<tfoot id='zjQoG'></tfoot>
  • <legend id='zjQoG'><style id='zjQoG'><dir id='zjQoG'><q id='zjQoG'></q></dir></style></legend>
    <i id='zjQoG'><tr id='zjQoG'><dt id='zjQoG'><q id='zjQoG'><span id='zjQoG'><b id='zjQoG'><form id='zjQoG'><ins id='zjQoG'></ins><ul id='zjQoG'></ul><sub id='zjQoG'></sub></form><legend id='zjQoG'></legend><bdo id='zjQoG'><pre id='zjQoG'><center id='zjQoG'></center></pre></bdo></b><th id='zjQoG'></th></span></q></dt></tr></i><div id='zjQoG'><tfoot id='zjQoG'></tfoot><dl id='zjQoG'><fieldset id='zjQoG'></fieldset></dl></div>
      <bdo id='zjQoG'></bdo><ul id='zjQoG'></ul>

      <small id='zjQoG'></small><noframes id='zjQoG'>

      1. 将 .NET 中的 DateTime 对象格式化为 Objective-c 的 N

        时间:2023-08-31
          <tfoot id='kHR1e'></tfoot>
            <bdo id='kHR1e'></bdo><ul id='kHR1e'></ul>

            • <small id='kHR1e'></small><noframes id='kHR1e'>

              <legend id='kHR1e'><style id='kHR1e'><dir id='kHR1e'><q id='kHR1e'></q></dir></style></legend>
            • <i id='kHR1e'><tr id='kHR1e'><dt id='kHR1e'><q id='kHR1e'><span id='kHR1e'><b id='kHR1e'><form id='kHR1e'><ins id='kHR1e'></ins><ul id='kHR1e'></ul><sub id='kHR1e'></sub></form><legend id='kHR1e'></legend><bdo id='kHR1e'><pre id='kHR1e'><center id='kHR1e'></center></pre></bdo></b><th id='kHR1e'></th></span></q></dt></tr></i><div id='kHR1e'><tfoot id='kHR1e'></tfoot><dl id='kHR1e'><fieldset id='kHR1e'></fieldset></dl></div>

                <tbody id='kHR1e'></tbody>
                  本文介绍了将 .NET 中的 DateTime 对象格式化为 Objective-c 的 NSDate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用一个将 .NET DateTime 对象返回到我的 iOS 应用程序的 API.我对发生的事情有点困惑,DateTime 在离开 API 时看起来很好,但是当它进入时,它会通过 JSON 并以如下所示的字符串形式进入:

                  I am working with an API that returns a .NET DateTime object into my iOS application. I'm a little confused at what's going on, the DateTime looks fine when it leaves the API, but when it comes in it goes through JSON and comes in as a string that looks like this:

                  /Date(1303884000000-0600)/
                  

                  WTF 是这样的,我怎样才能把它变成一个 NSDate 对象??

                  WTF is that and how can I turn it into a NSDate object??

                  谢谢!

                  推荐答案

                  来自 解析 JSON 日期iPhone 我觉得下面这个功能很完美:

                  From Parsing JSON dates on IPhone I found the following function to be perfect:

                      - (NSDate*) getDateFromJSON:(NSString *)dateString
                  {
                  // Expect date in this format "/Date(1268123281843)/"
                  int startPos = [dateString rangeOfString:@"("].location+1;
                  int endPos = [dateString rangeOfString:@")"].location;
                  NSRange range = NSMakeRange(startPos,endPos-startPos);
                  unsigned long long milliseconds = [[dateString substringWithRange:range] longLongValue];
                  NSLog(@"%llu",milliseconds);
                  NSTimeInterval interval = milliseconds/1000;
                  return [NSDate dateWithTimeIntervalSince1970:interval];
                  }
                  

                  这篇关于将 .NET 中的 DateTime 对象格式化为 Objective-c 的 NSDate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Objective-C如何打印出浮点数的前导0? 下一篇:xcode4模板格式问题

                  相关文章

                  最新文章

                  • <bdo id='n5FWB'></bdo><ul id='n5FWB'></ul>
                  1. <legend id='n5FWB'><style id='n5FWB'><dir id='n5FWB'><q id='n5FWB'></q></dir></style></legend>

                    <tfoot id='n5FWB'></tfoot>

                    <small id='n5FWB'></small><noframes id='n5FWB'>

                    1. <i id='n5FWB'><tr id='n5FWB'><dt id='n5FWB'><q id='n5FWB'><span id='n5FWB'><b id='n5FWB'><form id='n5FWB'><ins id='n5FWB'></ins><ul id='n5FWB'></ul><sub id='n5FWB'></sub></form><legend id='n5FWB'></legend><bdo id='n5FWB'><pre id='n5FWB'><center id='n5FWB'></center></pre></bdo></b><th id='n5FWB'></th></span></q></dt></tr></i><div id='n5FWB'><tfoot id='n5FWB'></tfoot><dl id='n5FWB'><fieldset id='n5FWB'></fieldset></dl></div>