美文网首页
处理时间

处理时间

作者: HunterG | 来源:发表于2016-07-02 12:41 被阅读22次

时间字符串的处理

这个是从网上找的例子,自己记录下来

    NSString* string = @"20110826134106";
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
    [inputFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] ];

    [inputFormatter setDateFormat:@"yyyyMMddHHmmss"];
    NSDate* inputDate = [inputFormatter dateFromString:string];
    NSLog(@"date = %@", inputDate);
    
    NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
    [outputFormatter setLocale:[NSLocale currentLocale]];
//    [outputFormatter setDateFormat:@"yyyy年MM月dd日 HH时mm分ss秒"];
    [outputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

    NSString *str = [outputFormatter stringFromDate:inputDate];
    NSLog(@"testDate:%@", str);
  • 输出结果如下
2016-07-02 12:39:29.064 CMCCMall[20437:7141275] date = 2011-08-26 05:41:06 +0000
2016-07-02 12:39:29.065 CMCCMall[20437:7141275] testDate:2011-08-26 13:41:06

相关文章

  • 时间处理:

    方法一: 时间类型 (例如:2017-01-01)在做时间处理的时候我们可以在数据库中将时间字段使用 bi...

  • 时间处理

    1.获取每周日0点的时间戳

  • 时间处理

    时间戳:(Unix timestamp),一种时间表示方式,从格林威治时间1970年01月01日00时00分00秒...

  • 处理时间

    当周围的有人忙忙碌碌时,不要受其影响,因为慌乱后的行为会散发出不可估量的愚蠢气味 有安逸生活时,就好好享受此时的安...

  • 处理时间

    /** * 处理时间 */ - (NSString *)timeWithTimeIntervalString:(N...

  • 处理时间

    时间字符串的处理 这个是从网上找的例子,自己记录下来 输出结果如下

  • 处理时间

    var oDate=new Date();//获取时间Thu Jan 12 2017 14:39:16 GMT+0...

  • 时间处理

    多线程使用DateFormat [Joda-Time] 是一个很棒的开源的 JDK 的日期和日历 API 的替代品...

  • 时间处理

    pandas小记:pandas时间序列分析和处理Timeserieshttps://blog.csdn.net/p...

  • 时间处理

网友评论

      本文标题:处理时间

      本文链接:https://www.haomeiwen.com/subject/kltfjttx.html