File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes iOS and the fly likes NSString to NSDate conversion problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » iOS
Bookmark "NSString to NSDate conversion problem" Watch "NSString to NSDate conversion problem" New topic
Author

NSString to NSDate conversion problem

Pratik Goswami
Ranch Hand

Joined: Mar 02, 2009
Posts: 136

Hi all,

I am having a NSString object which I am converting to NSDate with help of NSDateFormatter. Now code works fine here with all the OS but it is creating different Output at client's add (USA region).
Here is the code that I am using.


Output at my end -------2010-09-24 17:30:00 - 0700
Output at Client end ----2010-09-25 00:30:00 GMT

Can anyone please suggest where's the problem?

Thanks
Pratik Goswami


iOS * Android Developer
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
Try to set the locale of the date formatter.


Visit my blog: http://jnassef.blogspot.com/
Pratik Goswami
Ranch Hand

Joined: Mar 02, 2009
Posts: 136

Thanks Alaa,

The problem with the second output - '2010-09-25 00:30:00 GMT' is that if I do some calculation (adding minutes to NSDate) and converting again to NSDate creates problem, it automatically adds 7 hours to date. The problem is being created at client end only. At my end same logic works perfecly and produces exact result as expected.

Any idea?

Thanks
Pratik Goswami
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
I believe that this is a locale/timezone problem. As I've said before, try to set the locale of the date formatter, and see what happens.
christo kumar
Greenhorn

Joined: Oct 13, 2010
Posts: 1
Alaa Nassef wrote:I believe that this is a locale/timezone problem. As I've said before, try to set the locale of the date formatter, and see what happens.


Hi Alaa and Pratik,

Even I am facing the same problem, In my case [NSDate description] returning
Output at my end -------2010-09-24 17:30:00 - 0700
Output at Client end ----2010-09-25 00:30:00 GMT

Seems like related to iPhone setting or OS incompatibility thing,
Pratik if you resolved it please share.

Thanks
Christo

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NSString to NSDate conversion problem