objective-c 字符串、日期、Int转换
来源:互联网 发布:linux thread dump 编辑:程序博客网 时间:2024/06/09 21:03
1、字符串转换为日期
NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];//实例化一个NSDateFormatter对象
[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];//设定时间格式,这里可以设置成自己需要的格式
NSDate *date =[dateFormat dateFromString:@"1980-01-01 00:00:01"];
2、日期转换为字符串
NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];//实例化一个NSDateFormatter对象
[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];//设定时间格式,这里可以设置成自己需要的格式
NSString *currentDateStr = [dateFormat stringFromDate:[NSDate date]];
3、字符串转int
Convert NSString to int
NSString *aNumberString = @"123";
int i = [aNumberString intValue];
4、int转字符串
Convert int to NSString
int aNumber = 123;
NSString *aString = [NSString stringWithFormat:@"%d", aNumber];
- objective-c 字符串、日期、Int转换
- objective-c 字符串、日期、Int转换
- objective-c 中字符串与日期相互转换
- objective-c 日期和字符串的相互转换
- objective-c 中字符串与日期转换和比较
- objective-c 中字符串与日期转换和比较
- objective-c 中字符串与日期转换和比较
- objective-c 中字符串与日期转换和比较
- objective-c 中字符串与日期相互转换
- c 字符串转换int
- C#字符串,日期转换
- Objective-c 字符串 数组 转换
- Objective-C 【格式化日期时间字符串】
- objective-c与c字符串互相转换
- Objective-C 字符串与数值互相转换
- Objective-C 字符串与数值互相转换
- Objective-C -- 字符串与数字互相转换
- Objective-c之NSNumber与int之间的转换
- USB 基本知识
- 一个让我感触很深的求职故事,“请给我一次机会,让我成就你”
- java操作txt文件
- 五楼的七天
- Android4.0中AppWidget的一些新玩意体验
- objective-c 字符串、日期、Int转换
- JavaScript去除空格
- Linux 下使用命令行开发 Android 应用程序~~玩玩还行
- vim+ctags+taglist 安装使用
- html向flash传递参数的方法
- 什么是FastCGI?
- Android有关Please execute 'adb uninstall my.test' in a shell报错处理
- 缺页异常处理-do_page_fault
- java实现语音--转来学习