从 RSS 提要接收的日期中删除时间格式 iOS
Remove Time format from Date received from RSS Feed iOS
我正在从 RSS 提要中获取日期。这是 NSString 格式。
这就是我的 Feed class
@interface Feed : NSObject
{
}
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *link;
@property (nonatomic, strong) NSString *desc;
@property (nonatomic, strong) NSString *pubDate;
@property (nonatomic, strong) NSString *imageUrl;
这里pubDate
是NSString
当我 NSlong 这个时,它给了我正确的输出。
喜欢
Wed, 03 Jun 2015 00:00:00 GMT
现在我想删除这个00:00:00 GMT
我尝试了很多,搜索了很多,但在转换后它给了我 (null)
价值
我也试过这个 link
iOS getting date string from RSS Feed
这是我的日期转换代码,
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateFormat:@"dd-MM-yyyy"];
NSString *stringDate = [dateFormatter1 stringFromDate:feed.pubDate];
NSLog(@"final %@", stringDate);
最后的输出是
final (null)
试试这个可能对你有帮助...
NSLog(@"%@",[self ConvertDate_Format:feed.pubDate]);
//Pass Your date
-(NSString *)ConvertDate_Format:(NSString*)inputStirng
{
NSDateFormatter *dformat = [[NSDateFormatter alloc]init];
[dformat setDateFormat:@"EEE, dd-MMM-yyyy,hh:mm:ss"];
[dformat setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
NSDateFormatter * dateFormatter1 = [[NSDateFormatter alloc]init];
[dateFormatter1 setDateFormat:@"yyyy-MM-dd"];
[dateFormatter1 setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
return [dateFormatter1 stringFromDate:[dformat dateFromString:inputStirng]];
}
我正在从 RSS 提要中获取日期。这是 NSString 格式。
这就是我的 Feed class
@interface Feed : NSObject
{
}
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *link;
@property (nonatomic, strong) NSString *desc;
@property (nonatomic, strong) NSString *pubDate;
@property (nonatomic, strong) NSString *imageUrl;
这里pubDate
是NSString
当我 NSlong 这个时,它给了我正确的输出。
喜欢
Wed, 03 Jun 2015 00:00:00 GMT
现在我想删除这个00:00:00 GMT
我尝试了很多,搜索了很多,但在转换后它给了我 (null)
价值
我也试过这个 link iOS getting date string from RSS Feed
这是我的日期转换代码,
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateFormat:@"dd-MM-yyyy"];
NSString *stringDate = [dateFormatter1 stringFromDate:feed.pubDate];
NSLog(@"final %@", stringDate);
最后的输出是
final (null)
试试这个可能对你有帮助...
NSLog(@"%@",[self ConvertDate_Format:feed.pubDate]);
//Pass Your date
-(NSString *)ConvertDate_Format:(NSString*)inputStirng
{
NSDateFormatter *dformat = [[NSDateFormatter alloc]init];
[dformat setDateFormat:@"EEE, dd-MMM-yyyy,hh:mm:ss"];
[dformat setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
NSDateFormatter * dateFormatter1 = [[NSDateFormatter alloc]init];
[dateFormatter1 setDateFormat:@"yyyy-MM-dd"];
[dateFormatter1 setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
return [dateFormatter1 stringFromDate:[dformat dateFromString:inputStirng]];
}