美文网首页
阳历 -- > 阴历

阳历 -- > 阴历

作者: Rayla_周周 | 来源:发表于2016-09-19 11:11 被阅读0次

- (NSString *)getChineseCalendarWithDate:(NSInteger)day month:(NSInteger)month year:(NSInteger)year{

NSArray *chineseDays=[NSArray arrayWithObjects:

@"初一", @"初二", @"初三", @"初四", @"初五", @"初六", @"初七", @"初八", @"初九", @"初十",

@"十一", @"十二", @"十三", @"十四", @"十五", @"十六", @"十七", @"十八", @"十九", @"二十",

@"廿一", @"廿二", @"廿三", @"廿四", @"廿五", @"廿六", @"廿七", @"廿八", @"廿九", @"三十",  nil];

NSString* string;

if(month<10)

{

if (day < 10) {

string = [NSString stringWithFormat:@"%ld0%ld0%ld23",year,month,day];

}

else{

string = [NSString stringWithFormat:@"%ld0%ld%ld23",year,month,day];

}

}

else

{

if (day < 10) {

string = [NSString stringWithFormat:@"%ld%ld0%ld23",year,month,day];

}

else{

string = [NSString stringWithFormat:@"%ld%ld%ld23",year,month,day];

}

}

NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];

[inputFormatter setDateFormat:@"yyyyMMddHH"];

NSDate* inputDate = [inputFormatter dateFromString:string];

NSCalendar *localeCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierChinese];

unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth |  NSCalendarUnitDay;

NSDateComponents *localeComp = [localeCalendar components:unitFlags fromDate:inputDate];

NSString *d_str = [chineseDays objectAtIndex:localeComp.day-1];

return d_str;

}

相关文章

  • 阳历 -- > 阴历

    - (NSString *)getChineseCalendarWithDate:(NSInteger)day m...

  • 阴历阳历

    理论学习大会安排在六楼,要求全员必须参加,学习理论知识和文件。书记在台上热火朝天的讲,台下员工三两成群的讲着话,也...

  • 阳历,阴历

    女儿他们本打算上周五晚上回他们小家,又因周六晚上女婿得值班,于是改成周日下午回去,正好奶奶村里也解封了,他们来带几...

  • 《阴历与阳历》

    在中国现代日历上 阴历总在追赶着阳历 就像农村总在城市后 小孩总在大人后 冬天总在春天后 日夜不息,气喘咻咻 累了...

  • 阳历与阴历

    阳历是以地球围着太阳转一圈所经历的时间为一年,一年为365天分为12个月,俗称太阳历。 阴历则是以月...

  • 阴历和阳历

    我记得阳历的2021年新年,1月1日,不开心,回地大吃饭把塑料板凳坐坏,摔了一跤。最喜欢的裤子被戳破了一个...

  • Java阴历阳历互转

    package com.jxd.act; import java.util.Date; import java.u...

  • iOS阴历阳历互转

    前言 公司的APP需要日历,日历的需求需要阳历转换阴历(这个很好写),但是还需要阴历转换阳历。这个就非常的不好计算...

  • 农历阳历阴历说法

    赵之珩解释说,现在世界通用历法有3种:阳历、阴历和阴阳历。阳历是按照太阳两次通过春分点(即两次“春分”节气之间)的...

  • 生日过阴历还是阳历?

    猪猪真探社为你探索最真实的生活之理。 猪猪君就因为过生日这个事跟老婆闹得不愉快。 猪猪君生日是冬月初三,然后上身份...

网友评论

      本文标题:阳历 -- > 阴历

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