开发者

How to find the date format of a string

开发者 https://www.devze.com 2023-04-10 15:53 出处:网络
Is there a way (an elegant way that is) to extract a date format from a string containing a date so that it may be converted into an NSDate via NSDateFormatter?

Is there a way (an elegant way that is) to extract a date format from a string containing a date so that it may be converted into an NSDate via NSDateFormatter?

i.e

string = @"2011-1-10";
format = [extractor extractFormat:str开发者_C百科ing];// format would = yyyy-dd-mm
[formatter setDateFormatter:format];
NSDate * date = [formatter dateFromString:string];


If that is the only information you have then it is impossible. For example, "10-10-10".

0

精彩评论

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

关注公众号