Number shaped with two digits "behind the point" :-)

Hello

Please excuse my very bad English because I'm french :-)

I use the beta JDE v4.7 and the Blackberry Storm Simulator included.

I would like to know how to format a calculated result as #. # (a floating-point value with two digits "behind the point') to display in a RichTextField instance.

I tried this:

""""
String strSomme;
String strSommeTTC;
Double dblSomme;
Double dblSommeTTC;
               
strSomme = saisieField.getText ();
               
dblSomme = Double.parseDouble (strSomme);
dblSommeTTC = dblSomme * 119,6 / 100.0;
 
Trainer fmt = new Formatter();
 
strSommeTTC = fmt.formatNumber(dblSommeTTC,2);
 
RichTextField affichageField = new RichTextField ("sum TTC:" + strSommeTTC, Field.NON_FOCUSABLE);
Add (affichageField);
""""
 
Only the small portion of code compiles fine but I get an exception when you run the program in the Simulator: javax.microedition.global.UnsupportedLocaleException

I don't know if the Formatter class is the best way to convert a 45.528652541 to 45.53 number for example.

Thanks for any help.

Nice day.

Marc

I ended up writing a method to do this...

    final static String toString(double sum)
    {
        // Turn random double into a clean currency format (ie 2 decimal places)
        StringBuffer result;

        if (Math.abs(sum) < .01)
        {
            result = new StringBuffer("0.00");
        }
        else
        {
            if (sum > 0)
                sum = sum + 0.005;
            else
                sum = sum - 0.005;
            result = new StringBuffer(Double.toString(sum));
            final int point = result.toString().indexOf('.');
            if (point > 0)  // If has a decimal point, may need to clip off after 2 decimal places
            {
                if (point < (result.length()-2))  // eg "3.1415"
                {
                    result =  new StringBuffer(result.toString().substring(0,point+3));
                }
            }
        }
        return result.toString();
    }

I would like to know if there is a better way!

Tags: BlackBerry Developers

Similar Questions

  • variable with two digits after the point

    Hi all

    How can I specify variable to work with two numbers (one, three) after the point?

    e.q.

    Set one to 3.14159265358 like (lack of knowledge here)

    return a

    3.14 returned must

    It is a two-step process:

    Set A to 3.14159265358

    Set A (round (A * 100)) / 100

    The 100 can be changed as needed.

    (144176)

  • You can play with two players on the same conlsoe on modern war

    XXXXXXXXXXXXXX

    Hi Capcurt,

    Welcome to the Microsoft Answers site!

    You try to play the game live with 2 players on the same console?

    Unfortunately, you can not go online with two people on the same console. Modern Warfare 2 allows a user to sign in when you play in multiplayer.

    Modern Warfare 2 is a completely new game mode that supports 2-player cooperative play in single line of the solo campaign in history. To do this, you will need two machines.

    For better support, you can contact Xbox Forums.

    http://www.xbox360forum.com/Forum/

    Hope this information is useful.

    Amrita M

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • When you add pictures to the Vista image folder it creates a folder HIDDEN of the same name with two copies of the same image inside

    I use Vista 32 bit. I started to see this problem when I recently copy photos from an SD card.

    When you add pictures to the Vista image folder it creates a folder HIDDEN of the same name with two copies of the same image inside

    I saw hidden files enabled in folder options.

    Any help is appreciated.

    Hey guys... I found the answer... Problem is with the software vaio content analyzer that comes with the vaio...

    It just search for Vaio Content Analyzer (parameters) and deselect

    Video analysis
    image analysis
    analysis of the music

    I went looking for this crazy thing... used almost all types of online scan, and finally to find that it is caused by an internal software only...
    anyway thanks to all... Hope it helps someone in the future :)
  • Can I convert a ppt file to PDF with PDF Pack with two blades to the page?

    I want to convert a ppt file to pdf format with two blades on the page, rather than a slide page. I can do this with a printer. How do I do this with pdf pack?

    Hi sandyd,.

    When you convert PowerPoint to PDF via Adobe PDF Pack, it will convert each slide in the deck to a page in the PDF file. Unfortunately, there is no way to change this.

    Best,

    Sara

  • What is the name of the circular icon with two swings in the content panel?

    Adobe Bridge CS5

    Win 7 Pro 64-bit

    What is the name of the circular icon with two swings in the Panel content above the thumbnail image of a raw file? I can't find documentation about it.

    Thanks in advance.

    Thanks for the keyword "badge".

    With that, I found it's called a

    "Badge of parameters.

    There is also a badge of culture which has an icon of culture.

  • Satellite Pro 2100 two cables behind the screen

    Hi, first post so be gentle with me please.

    I have a Satellite Pro Satellite Pro 2100 and the hinges are shot, so I bought a 2100 piece to Exchange.
    Everything was ok except that I have two sons that I can't find a place to plug in. A black white and they are attached to the small square gold Ribbons that are glued to each top corner at the back of the screen. The other ends have little, but when I stripped the laptop they were in bulk and I do not see where they are going.

    However, the laptop works fine without them.
    Can anyone help please?

    All laptops with WLAN have this. WLAN antenna is placed behind the screen and these two wires must be connected to the WLAN antenna.

    If your laptop doesn't have WLAN card put just the cables aside and everything will be OK.

  • Is there a way to create a topic with a shading behind the text and fine lines above and below?

    I work with InDesign CS6, Windows 7.

    Is it possible, using nets of paragraph, to create a heading with shading behind the text and fine lines above and below the text?

    I would like to create headers that resemble these:

    Headings.png

    Thank you!

    A way to create a style of stoke (Stripe type) with a small percentage of height up and downstairs dedicated to scratches, then apply the color out in the dialog whn would you apply the contour to your net of paragraph style. The downside to this is that the 'weight' of the two lines can vary when you change the weight of the actual race.

    To avoid this and still be able to ge the fill to expand the width of column, you can use a 1-cell table, or you could use rules above and below and underscore cutom for filling and key line with a tabulation of withdrawal right. If you need space on the left, as shown in the illustration, you would probably need a tab on the left as well, instead of a dash.

  • all characters replaced by square with two zeros on the top and a number below, works ok when uninstall it, reload and start the first time, after that the problem reappears. sometimes works first time to reboot. IE and Chrome ok, light running. v 7, wind

    Set up of fonts etc seems to be ok, still had problems with plug-ins disabled

    Try to set the pref gfx.font_rendering.directwrite.use_gdi_table_loading false on the topic: config page.

    To open the topic: config page, type Subject: config in the address bar (address) and press the 'Enter' key, as you type the url of a Web site to open a Web site.

    If you see a warning then you can confirm that you want to access this page.

    • Use the filter at the top bar of the on: page config to more easily spot a preference.
    • Preferences that have changed also show "BOLD" (user set).
    • Preferences can be reset to the default value using the context menu if they are set of users
    • Preferences can be changed via the context menu: Edit (string or integer) or toggle (Boolean)
  • Switcher with two facets for the recording of the update and one for folder creation

    Hello world

    I have a little problem.

    I use a mixer so that the function of the key, I click on the form is either loaded with the row of data update or a new form.

    I use two facet on which support the current line using an executewithparams and a different side with just a form of creation.


    But each form are blank



    It is with my links and executables that they must be in a specific order or what

    Help, please


    Concerning
    Lutchumaya

    Hello

    as signaller is not the right choice. If you use the ADF BC, then the same form is used for both and all you need to do is call createInsert as an operation at the opening of the Form by creating a new line and calling setCurrentRowWithKey when opening it to change

    Frank

  • How to solve the problems of synchronization with iCloud photos? The point, reset sync requested version mismatch.

    Hello

    I have trouble downloading to iCloud the photos app in OS X.

    It seems pictures are being developed and download is underway, until I reached a point where the download starts from the beginning again and the console shows the following message is displayed:

    25/07/16 09:31:36, cloudphotosd 148 [315]: Reset Sync asked! Reason: Domain = CloudPhotoLibraryErrorDomain Code = 1 "version mismatch" error UserInfo = {NSLocalizedDescription = Version mismatch}

    Does anyone know how difficult or can help me debug the problem?

    It seems that the problem is related to evolution of photos from hidden to visible, and vice versa. or remove the tags to images (maybe generally, no changes to photos) before the download is finished, because that's what I was doing in the meantime.

    Thanks for your help!

    Version:

    OS X 10.11.6 (15G 31)

    Photos App Version 1.5 (370.42.0)

    one thing to try is disabling ICPL on all devices and disconnect from iCLoud then reconnect you and put on a device at a time and see if that clears it

    LN

  • UDP with two ethernet of the Compactrio system

    Hello

    Here's my problem, I have to do a UDP data transfer,

    I want to write on another computer using two ethernet of a compactRIO (9022) .txt

    I'm doing a schema to be more clear:

    http://www.hostingpics.NET/Viewer.php?id=470011reseaujpg.jpg

    I have to work on a project in real time, so here's my program:

    http://www.hostingpics.NET/Viewer.php?id=568811myprogjpg.PNG

    So the data are send to the first ethernet then write on the second ethernet (first put in a loop).

    Then the data is read on the second ethernet and send in the third second computer C://abc.txt loop), (the second loop is useless..)

    I have a few problems:

    1: when I try the program I have a 54 error that says something like this "the network address is malformed and must be of type of XXX.XXX.XXX.XXX.

    2nd: I do not give the ip address of the computer, I think that he'll never find it, what should I do?

    Thank you to have responded and sorry my English isn't great...

    Please help :/

  • JIT - ACM with two Instance of the Ethernet on the same interface Service

    Hi all

    I develop script of EEM for platform of ASR903... I would define VCA two, one for each 'host' connected to the same interface of ASR903 (GI 0/1).

    Each host sends CFM package, I will know which CVS the CFM package arrives. In the EEM scripting language, there are the following variable: $_ethernet_intf_name that can be used to retrieve the name of the interface. Is there another variable that can be used to recognize the VCA or is there any syslog message that conatins this information?

    CFM Ethernet ieee

    Ethernet global cfm

    field of Ethernet HOST1 level 2 cfm

    Service vlan301 evc301 evc vlan 1301 direction downwards

    continuity check

    !

    CFM Ethernet ieee

    Ethernet global cfm

    area of cfm Ethernet HOST2 level 3

    Service vlan301 evc302 evc vlan 1302 direction downwards

    continuity check

    !

    VCA evc301 Ethernet

    VCA evc302 Ethernet

    !

    interface GigabitEthernet0/1

    ink description to ASR - 903 by microwave

    no ip address

    load-interval 30

    auto negotiation

    Ethernet microwave hold sending 10 event

    Ethernet microwave wtr event 5

    Ethernet microwave-threshold of loss of 255 event

    !

    service instance 301 ethernet evc301

    encapsulation dot1q 301

    rewrite tag pop 1 symmetrical penetration

    Bridge-domain 301

    CFM mep field HOST1 mpid 101

    CFM encapsulation dot1q 301

    !

    service instance 302 ethernet evc302

    encapsulation dot1q 302

    rewrite tag pop 1 symmetrical penetration

    Bridge-domain 302

    mep field HOST2 mpid 102 cfm

    CFM encapsulation dot1q 302

    !

    Ah, ethernet OAM.  I've never used the detector of this event, so I don't know what capabilities are available.  I don't have a handy to test myself ASR903.  You can run the command "show event handler detector ethernet detail" to see what built-in variables are available to your EEM ethernet event policy.  You can also do "display event handler detector all ' to see all detectors of the event.  I hope you see something out there that specifies the VCA.

    If this isn't the case, you certainly could extract something like a syslog message if a message is generated that contains the name of EVC.  Still, I don't know what syslogs are generated, so you should test yourself.

  • Maps JSON data with two data in the list

    Hey all,.

    Been working with JSON data and informing the lists for a some time now, but im stuck now on a single set of data.

    The data structure is the following:

    [
         {
              data: {
                   children: [ {
                        {}
                        {}
                        {}
                   } ]
               }
         }
    
         {
              data: {
                   children: [ {
                        {}
                        {}
                        {}
                   } ]
               }
         }
    ]
    

    The data that I take care of normally contains one of these structures and not 2 as in the above data. So what follows could could work:

                                    const QByteArray response(reply->readAll());
            ArrayDataModel *model = new ArrayDataModel();
    
            bb::data::JsonDataAccess jda;
            QVariantMap results = jda.loadFromBuffer(response).toMap();
            QVariantList children = results["data"].toMap()["children"].toList();
    
            model->append(children);
            mListView->setDataModel(model);
    

    However, it is now giving me an empty list. So how can I limit the above code to analyze and insert only the 2nd set of JSON data in the list?

    Please let me know if it needs to be clarified. Any help is appreciated. Thank you!

    Hello

    It contains a list of maps. Have you tried something like the following:

    bb::data::JsonDataAccess jda;
    QVariantList results = jda.loadFromBuffer(response).toList();if (results.size() >= 2){
        QVariantMap secondSet = results.at(1).toMap(); // to get the second map
        QVariantList children = secondSet["data"].toMap()["children"].toList();
        model->append(children);}
    
  • Bluetooth connection with two devices at the same time? (on TX)

    I have a Palm TX and am trying to connect to the Palm Bluetooth keyboard wireless AND my cell phone of Nokia (Internet, etc.) at the same time.  The TX works very well with each device individually.  However, when I try to use them together, it won't work.  If I connect the keyboard first, then try to connect to the phone for internet access, it automatically CUTS the keyboard; and vice versa - any order of connection, it will cut the previous when it is connected.  (If the keyboard is connected and I use a fast connection button to go directly to the internet, when he tries to connect it will say that the port/cable is bad and can not connect.)

    (I know generally that a bluetooth device can support up to 7 other devices in its network and I've read where people supposed to logged keyboards and phones to the TX before I bought the keyboard).

    Any help is appreciated!

    fitnessdr wrote:

    Thank you for the information.  So if I had to return the new bluetooth keyboard, should I get the 'Palm 3169WWZ Wireless Keyboard", or y at - it another model I should look for?  (From what I can tell, I think he will use IR)

    Thank you!

    Well, that's the one I use.

    Don't forget to download the driver for the more recent (1.13) for the keyboard in the Palm Support pages for the keyboard:

    http://KB.Palm.com/wps/portal/KB/na/keyboards/palmuniversalwirelesskeyboard/unlocked/downloads/page_en.html

    Do not install the driver provided with the device on the disc - 1.13 is designed for the TX and fixes a bug that existed in the original pilot.

    WyreNut

Maybe you are looking for

  • lock the images (how it happened)

    Hi guys,. I just use app to find my images in doubles, from there, I just don't see that I have a lot of images that I have; are the lock. How this happen? I don't know that I'm not done it. TQ

  • Invalid redeem Code

    I already bought a $ 50 gift card in an online store, and he sent me an e-mail 16-digit code. But when I want to enter my code in my iPhone, I'm dealing with this error "this CODE has ALREADY BEEN USED. Now, I want to know if there is a problem with

  • Tecra M9 crashes when the apparatus or the lid close on Windows Vista Business

    Hello I have a Tecra M9 with Windows Vista business, and when I close the lid on the laptop that Windows puts on hold. When I open the lid, although wakes up the computer screen but it crashes. Even if I have the machine on the docking station when I

  • password reset * address email is removed from the privacy *.

    E-mail address is removed from the privacy * please answer to this address.

  • Windows XP wireless network

    Automatic Configuration of Windows service stops after every awakening upward. It is configured to run automatically.