Blackberry Numeric Formatted Output – You’re SOL

Blackberry Numeric Formatted Output – You’re SOL

If you’ve tried to do some basic formatting for – oh say – currency or thousands-separated floating point numbers in Blackberry Java, you quickly realize something:

You’re spit outta luck.

For you old C developers, I daresay you can’t do without printf, fprintf, or sprintf for doing external and internal string formatting.

But somehow, the geniuses behind Blackberry failed to supply one of the most basic elements used by developers in their apps – the ability to easily format numeric strings for output.

It’s not like Java doesn’t have a Formatter class – it’s just that Blackberry’s version of it doesn’t support locale-specific decimal points and separators. So, something like Formatter fmt = new Formatter("###,###.00") – which works like a charm in most Java environments and on Android – is exception city on Blackberry.

In short, you’re screwed.

There is a solution – write your own formatter (ugh).

The fine folks at Sun do have a sample implementation of a Java printf analog (http://java.sun.com/developer/technicalArticles/Programming/sprintf/PrintfFormat.java). Unfortunately, they prohibit it’s use in commercial applications. Which means it’s worthless as a solution for professional developers.

This may seem like a trivial thing.

Except that you have to take time away from doing real project work to fix a shortcoming in the Blackberry SDK, so that your app can have basic numeric and currency string formatting.

And for those playing along at home, time is money. You heard it here first.

There really isn’t an excuse for this type of shortcoming, in a product line years on the market.

Advertisements

2 thoughts on “Blackberry Numeric Formatted Output – You’re SOL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s