开发者

How to add characters to a NSString?

开发者 https://www.devze.com 2023-03-07 23:58 出处:网络
i have strings who look like this 20110525 . how can i make to put \'-\' caractersin NSString variable ? to let dates look like this 2011-05-25 ?

i have strings who look like this 20110525 .

How to add characters to a NSString?

how can i make to put '-' caracters in NSString variable ? to let dates look like this 2011-05-25 ? My second question is how can i sort the dat开发者_如何学Goes to make the table look like this 20110525 then 20110526 ?Help please . Thank you


Why not just use the NSDate class to get the date, and use an NSDateFormatter to format the date the way you want.


you can try using sscanf(input,"%4d%2d%2s",&year,&month,&day) to parse input string and sprintf(output,"%d-%d-%d",year,month,day) to format your date.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号