nsdateformatter

NSDateFormatter memory leak?

别等时光非礼了梦想. 提交于 2019-12-12 02:16:51
问题 I have a problem with NSDateFormatter dateFromString: method. There is an array of dictionaries with string dates and I want to convert them to NSDates . But there is a huge heap growth every time I call this method (I need to call it more than once, cause it's an "update" method). Also I call it in background thread and ARC is on. What am I doing wrong? Any help, please. UPDATE: Full code of the function: - (GraphController *) initGraphWithData: (NSArray *) points forInterval: (GraphInterval

NSDate from NSString , shows the previous day

ぃ、小莉子 提交于 2019-12-12 02:03:13
问题 I have s imple NSDate from NSString as below NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd"]; issueDatabase.album_date = [dateFormatter dateFromString:albumXML.album_date]; but for some reason I'm getting the previous day instead of the current for eample if my albumXML.album_date is equal 2011-09-01 I'm getting the following stored in my database 2011-08-31 回答1: You need to set a timezone to your dateFormatter: [dateFormatter

NSDateFormatter is showing wrong date format (nachm. instead of PM) in the simulator

断了今生、忘了曾经 提交于 2019-12-12 01:33:51
问题 Why does the simulator is showing me 10:30 nachm. instead of 10:30 PM ? I use the following code: NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat: @"h:mm a"]; NSLog(@"%@",[dateformat stringFromDate: myDate]); OK I think I have to set a Locale somewhere ... 回答1: I think the language in your simulator is set to German. Than nachm. means Nachmittags. And that's equal to PM. Take a look at the settings in the simulator. ;-) 来源: https://stackoverflow.com

Save date in 'GMT' timezone in sqlite database

ぃ、小莉子 提交于 2019-12-12 01:26:28
问题 I am using Core-Data to store date-time object. Eg. 2015-07-28T07:16:52+0000 this is date in ISO format in GMT timezone. But when I save this date in database NSString* dateString=@"2015-07-28T07:16:52+0000"; NSDateFormatter* dateTimeformatter=[[NSDateFormatter alloc] init]; [dateTimeformatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; [dateTimeformatter dateFromString:dateString]; the resulting date which I see in database is 2015-07-28 12:46:52 which is in IST according to my device's

IST time zone not getting parsed

别说谁变了你拦得住时间么 提交于 2019-12-12 01:09:17
问题 I have a string Tue Feb 23 10:12:48 IST 2014 , I want to get the NSdate object form this. I am using below code snippet NSString * buildTime = @"Tue Feb 23 10:12:48 IST 2014"; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"EEE MMM dd HH:mm:ss ZZZ yyyy"]; NSDate *date = [formatter dateFromString:buildTime ]; Every time I am getting nil value to date variable. If I am changing IST to GMT in build time then NSDate is perfectly coming. Can any one correct

NSDateFormatter dateFromString conversion

人走茶凉 提交于 2019-12-11 20:29:10
问题 I am having problems with conversion of NSString object to NSDate. Here is what I want to do: I am downloading an RSS Message from the internet. I have the whole message parsed by NSXMLParser. After that, I have parts like , or saved to particular NSStrings. I want to convert element (that includes publication date of RSS Message) to NSDate so that I could perform some operations on it like on a date object (e.g. sorting, showing on a clock etc.). Here is the way my looks like: "Wed, 25 Sep

Parse check if object was created today? Objective-C

跟風遠走 提交于 2019-12-11 19:39:26
问题 I am trying to write a PFQuery for my application that returns only objects that were created today. With all the depreciations that happened to NSDate and the growing importance of NSDateFormatter I am finding rather hard to go about this. I have figured the logic to be like this in pseudo-code: Query q = new Query(); q.whereDateGreaterThan(midnightThisMorning); q.whereDateLessThan(midnightTonight); I can't seem to figure out how to get a NSDate object set to 12:00 AM (which would be

NSDateFormatter strange behavior for very old dates

混江龙づ霸主 提交于 2019-12-11 18:54:25
问题 I am using NSDateFormatter in the following way: NSDateFormatter *formatter = AUTORELEASE([[NSDateFormatter alloc] init]); [formatter setDateStyle:dateStyle]; [formatter setTimeStyle:timeStyle]; return [formatter stringFromDate:date]; This returns me the correct date & time if the year in "date" is greater than 1893 . If I specify a date with an year < 1893 , It gives me wrong time but correct date. The time usually has a difference of 7 min from the correct time. Has anyone faced similar

Get Month and year of 1 year advance in iPhone

我怕爱的太早我们不能终老 提交于 2019-12-11 18:35:46
问题 in my app I need to get month name and year for next 1 year and store in array. I mean to say suppose today's September 2012, I need month name and year till August 2013. Can you please tell me how will I get month and year? Thanx in advance 回答1: Use the NSMonthCalendarUnit for the components parameter of the current calendar to get the number of the current month, e.g. 9 for September and then NSYearCalendarUnit for the current year, e.g. 2012. Then use these in a for loop which uses modulus

incorrect string to date conversion swift 3.0

纵饮孤独 提交于 2019-12-11 17:11:38
问题 I am converting a format like 10/24 12:00 PM in string to the equivalent in Date format. I am using the following code: let dateFormatter = DateFormatter() dateFormatter.dateFormat = "MM/dd hh:mm aa" self.dateCompleted = dateFormatter.date(from: self.DeliverBy!) dateCompleted is a Date variable whereas self.DeliveryBy is a String variable. I am getting an output like 2000-10-24 17:00:00 UTC where as it should be something like 2017-10-24 12:00:00 UTC. Am i doing something wrong? I referred