NSDate 日期类型的使用
来源:互联网 发布:二叉树的深度算法 编辑:程序博客网 时间:2024/04/30 02:00
#import "ViewController.h"
#import "ChineseCalendarDate.h"
@interface ViewController ()
@property(nonatomic,assign)UILabel *label;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// NSDate *date = [NSDate date];
// NSString *str =[NSString stringWithFormat:@"%@",date];
// NSLog(@"%@",str);
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(150, 100, 200, 50)];
label.textAlignment = NSTextAlignmentLeft;
label.font = [UIFont boldSystemFontOfSize:15];
label.textColor = [UIColor colorWithRed:0.249 green:0.220 blue:1.000 alpha:1.000];
self.label = label;
[self.view addSubview:self.label];
NSDateFormatter *dateformat = [[NSDateFormatter alloc]init];
//设置日期格式
[dateformat setDateFormat:@"YYYY-mm-dd"];
NSString *dateString = [dateformat stringFromDate:[NSDate date]];
label.text = dateString;
}
-(IBAction)getDate:(id)sender
{
[self getDate];
}
-(void)getDate
{
NSDate *date = [NSDate date];
NSString *str =[NSString stringWithFormat:@"%@",date];
NSLog(@"%@",str);
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(150, 200, 200, 50)];
label.textAlignment = NSTextAlignmentLeft;
label.font = [UIFont boldSystemFontOfSize:15];
label.textColor = [UIColor colorWithRed:0.655 green:1.000 blue:0.546 alpha:1.000];
self.label = label;
[self.view addSubview:self.label];
NSDateFormatter *dateformat = [[NSDateFormatter alloc]init];
//设置日期格式
[dateformat setDateFormat:@"YYYY-mm-dd"];
NSString *dateString = [dateformat stringFromDate:[NSDate date]];
NSLog(@"%@",date);
ChineseCalendarDate *date1 = [ChineseCalendarDate getChineseCalendarWithDate:date];
NSLog(@"%@",date1);
label.text = date1;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
#import "ChineseCalendarDate.h"
@interface ViewController ()
@property(nonatomic,assign)UILabel *label;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// NSDate *date = [NSDate date];
// NSString *str =[NSString stringWithFormat:@"%@",date];
// NSLog(@"%@",str);
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(150, 100, 200, 50)];
label.textAlignment = NSTextAlignmentLeft;
label.font = [UIFont boldSystemFontOfSize:15];
label.textColor = [UIColor colorWithRed:0.249 green:0.220 blue:1.000 alpha:1.000];
self.label = label;
[self.view addSubview:self.label];
NSDateFormatter *dateformat = [[NSDateFormatter alloc]init];
//设置日期格式
[dateformat setDateFormat:@"YYYY-mm-dd"];
NSString *dateString = [dateformat stringFromDate:[NSDate date]];
label.text = dateString;
}
-(IBAction)getDate:(id)sender
{
[self getDate];
}
-(void)getDate
{
NSDate *date = [NSDate date];
NSString *str =[NSString stringWithFormat:@"%@",date];
NSLog(@"%@",str);
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(150, 200, 200, 50)];
label.textAlignment = NSTextAlignmentLeft;
label.font = [UIFont boldSystemFontOfSize:15];
label.textColor = [UIColor colorWithRed:0.655 green:1.000 blue:0.546 alpha:1.000];
self.label = label;
[self.view addSubview:self.label];
NSDateFormatter *dateformat = [[NSDateFormatter alloc]init];
//设置日期格式
[dateformat setDateFormat:@"YYYY-mm-dd"];
NSString *dateString = [dateformat stringFromDate:[NSDate date]];
NSLog(@"%@",date);
ChineseCalendarDate *date1 = [ChineseCalendarDate getChineseCalendarWithDate:date];
NSLog(@"%@",date1);
label.text = date1;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
0 0
- NSDate 日期类型的使用
- NSDate 日期类的使用
- C27_OC17-日期类型NSDate
- 日期时间类NSdate的使用
- NSDate日期的类
- NSDate 获取某个日期之前的日期
- 日期类NSDate与日期格式化类NSDateFormatter类的使用
- NSDate --- 日期
- NSDate日期
- NSDate的使用
- nsdate的使用
- NSDate的使用
- NSDate的使用
- NSDate 的简单使用
- NSDate, NSDateFormatter的使用
- NSDate的使用
- NSDate的使用
- NSDate的使用
- 比较电路交换、分组交换、ATM交换的异同
- Mysql基础语法总结
- 怎么样简单快速的将pdf保存为图片--三部曲
- Codeblocks 574D,DP
- UIday0604:UIControl 的属性和用法
- NSDate 日期类型的使用
- Windows消息机制要点
- springMVC之增删改查(RESTful),springmvcrestful
- 574A
- ubuntu11.10 安装tpc_w
- 常见的设计模式
- 【Java】JAVA反射机制
- Springmvc构造RESTful详细讲解
- typedef union bit-field