• 日期


    一、根据日期获得周

    - (NSString*)getInforFromTime:(NSString*)time

    {

        if (time.length == 0) {

            return @"";

        }

        NSString* winInfor = @"";

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

        dateF.dateFormat = @"yyyy-MM-dd";

        NSDate *date = [dateF dateFromString:time];

      

        NSCalendar *calendar = [NSCalendar currentCalendar];

        NSInteger unitFlags = NSWeekCalendarUnit|NSWeekdayCalendarUnit;

        NSDateComponents *comps = [calendar components:unitFlags fromDate:date];

        switch ([comps weekday]) {

            case 1:

                winInfor = [winInfor stringByAppendingString:@"周日"];

                break;

            case 2:

                winInfor = [winInfor stringByAppendingString:@"周一"];

                break;

            case 3:

                winInfor = [winInfor stringByAppendingString:@"周二"];

                break;

            case 4:

                winInfor = [winInfor stringByAppendingString:@"周三"];

                break;

            case 5:

                winInfor = [winInfor stringByAppendingString:@"周四"];

                break;

            case 6:

                winInfor = [winInfor stringByAppendingString:@"周五"];

                break;

            case 7:

                winInfor = [winInfor stringByAppendingString:@"周六"];

                break;

            default:

                winInfor = [winInfor stringByAppendingString:@"未知"];

                break;

        }

        NSArray* timeArray = [time componentsSeparatedByString:@"-"];

        if ([timeArray count] == 3) {

           winInfor = [winInfor stringByAppendingFormat:@" %@月%@日", [timeArray objectAtIndex:1], [timeArray objectAtIndex:2]];

        }

        return winInfor;

    }

  • 相关阅读:
    oracle转义用单引号
    【转】plsql 永久注册码适用个版本
    winform datagridview某一列设为自动宽度
    Allow windows service to "Interact with desktop"
    Format a Hard Drive in Csharp C#格式化总结
    Lib New
    大嫂的HTML
    ASP.NET 分页控件
    linux搭建常用命令(运行jar,查看进程)
    如何用navicat连接linux服务器上的mysql以及重启服务
  • 原文地址:https://www.cnblogs.com/swallow37/p/3867999.html
Copyright © 2020-2023  润新知