Re: Zero-padding an NSNumberFormatter
Re: Zero-padding an NSNumberFormatter
- Subject: Re: Zero-padding an NSNumberFormatter
- From: Keary Suska <email@hidden>
- Date: Tue, 09 Jan 2007 12:50:11 -0700
- Thread-topic: Zero-padding an NSNumberFormatter
on 1/8/07 6:45 PM, email@hidden purportedly said:
> I've RTFM'd and STFA'd and still don't get something...
>
> I want to create an NSNumberFormatter that shows time offsets, so
> that a positive offset (like 700) becomes +0700, a negative offset
> becomes -0700, etc. Here's what I'm trying:
>
> NSNumberFormatter *offsetFormatter = [[[NSNumberFormatter alloc]
> init] autorelease];
>
> [offsetFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
> [offsetFormatter setFormat:@"+0000;+0000;-0000"];
> [offsetFormatter setUsesGroupingSeparator:NO];
> [offsetFormatter setAllowsFloats:NO];
> [offsetFormatter setMaximumIntegerDigits:4];
> [offsetFormatter setMinimumIntegerDigits:4];
> [offsetFormatter setPaddingCharacter:@"0"];
>
> But when I plug the number -700 into this, the resulting string is "-
> +2++". I expected it to be "-0700". Not only is the hundredths-place
> number wrong, but the zero-padding is replaced by plus-padding.
> However, when I plug in 0 I get the expected result ("+0000").
What happens when you use -setPositivePrefix: instead of specifying in the
format?
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden