Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
ibarrera
Posts: 588
Registered: ‎05-29-2009

DecimalFormat

I think we can't use that class... do you know how to format numbers to a certain number of decimal places?
Please use plain text.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Carrier: ***

Re: DecimalFormat

Check net.rim.device.api.i18n.MessageFormat class

 

It is compatible with J2SE MessageFormat class:

 

http://java.sun.com/j2se/1.3/docs/api/java/text/MessageFormat.html

Please use plain text.
Developer
ibarrera
Posts: 588
Registered: ‎05-29-2009

Re: DecimalFormat

Thanks for your answer. I'm trying to format a Double and get 5 decimal precision, but it doesn't seem to work, i don't get anything... i'm doing this... 

 

    MessageFormat mf = new MessageFormat("{#.#####}");
    Object[] objLa = {new Double(latitud)};
    String latitudF = mf.format(objLa);

 

Any ideas?

Please use plain text.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Carrier: ***

Re: DecimalFormat

Check this link for custom formatting methods:

 

http://www.horstmann.com/corejava/Format.java

Please use plain text.
Developer
lucidbee
Posts: 86
Registered: ‎07-21-2009

Re: DecimalFormat

The link you ref (horstmann...) is for non-commercial use only.

I need this functionality for a commercial app. 

Any links, tips, pointers? 

thanks!

lucidbee

Please use plain text.
New Developer
edeandrea
Posts: 4
Registered: ‎10-19-2009

Re: DecimalFormat

It seems that the MessageFormat class does not yet support numbers...See this post:

 

http://supportforums.blackberry.com/t5/Java-Development/Formatting-a-floating-point-number/m-p/31590...

Please use plain text.
Developer
swiebertje
Posts: 64
Registered: ‎05-09-2009

Re: DecimalFormat

It's really crappy RIM does not support these standard Java libraries, this makes development often very frustrating. When i look at the Android libraries for example it's just there.

Please use plain text.
Developer
chengbang69
Posts: 62
Registered: ‎01-22-2010
My Carrier: Globe

Re: DecimalFormat

hi ibarrera, what did you do to achieve Decimal formatting?

Please use plain text.