小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

ios 時間的比較&&獲得系統(tǒng)本地時間指定時區(qū)

 plumbiossom 2014-05-13

- (BOOL)isEqualToDate:(NSDate *)otherDate;

    與otherDate比較,相同返回YES


    - (NSDate *)earlierDate:(NSDate *)anotherDate;

    與anotherDate比較,返回較早的那個日期


    - (NSDate *)laterDate:(NSDate *)anotherDate;

    與anotherDate比較,返回較晚的那個日期



    - (NSComparisonResult)compare:(NSDate *)other;

    該方法用于排序時調用:

      . 當實例保存的日期值與anotherDate相同時返回NSOrderedSame

      . 當實例保存的日期值晚于anotherDate時返回NSOrderedDescending

      . 當實例保存的日期值早于anotherDate時返回NSOrderedAscending

 // 獲得本地時間指定時區(qū)
                    NSDate *dates = [NSDate date];
                    NSDateFormatter *formatter =  [[NSDateFormatter alloc] init];
                    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/beijing"];
                    [formatter setTimeZone:timeZone];
                    NSString *loctime = [formatter stringFromDate:dates];


(NSDate *) stringToDate:string
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *date = [dateFormatter dateFromString:string];
    [dateFormatter release];
    return date;
}

-(NSInteger)daysWithinEraFromDate:(NSDate *) startDate toDate:(NSDate *) endDate
{
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    unsigned int unitFlags = NSDayCalendarUnit;
    NSDateComponents *comps = [gregorian components:unitFlags fromDate:startDate  toDate:endDate  options:0];
    int days = [comps day];
    return days;
}

    本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多