Reputation: 2369
guys
I have two question to ask, they're easy, but bothering me for a while.
I access my .NET test WebService, and it return two parameters to me.
One is a date data just like "/Date(1332399761677+0800)/", and I dont know
how to format it to the normal date format.
Two is a NSString data looks like "12000.00000",and I want to change it to
the format like this:"12000.00".
So,please help me with this two problems. Thank you in advance.
Upvotes: 0
Views: 210
Reputation: 16725
1332399761677
looks like a Unix date, so if you grab that part of the string, use NSString doubleValue
to turn it into a double, then use NSDate dateWithTimeIntervalSince1970:
, you should be able to get a date. +0800
looks like a timezone, but you wouldn't need the timezone to get the date given a Unix date: 1332399761677
would specify a specific point in time, irrespective of timezones.
As for "12000.00000", you would use doubleValue
to make it into a double, make an NSNumberFormatter
with its maximumFractionDigits
and minimumFractionDigits
set to 2, then use stringFromNumber:
.
Upvotes: 1