How to right-align numbers with DecimalFormat

I want this form of output:
(0 is really a space, but this forum doesn't allow the leading spaces.)
0023
0005
0324
0011
4972
0008
0055
What should be the pattern givent to the DecimalFormat constructor?
Or, other way around?

example :
    public static String rightAlign(int totalLength, int number)
        String text = String.valueOf(number);
        int remainLength = totalLength - text.length();
        if (remainLength > 0)
            char [] blank = new char [remainLength];
            Arrays.fill(blank, ' ');
            text = String.valueOf(blank) + text;
        return text;
    }

Similar Messages

  • How to right align a read only numeric field in a panel form layout

    Hi, does anyone know how to right align a read only numeric field in a panel form layout? I am using: Style Class = AFFieldNumberMarker, but it only seems to work if the field is disabled. Disabling the field gives it a difference appearance that does not look right on our forms. These are calculated fields, which cannot be modified, so read only is necessary.
    I have looked online for some answers, and it seems that others are having similar issues.
    I have tried different combinations for the properties, but so far I cannot get it to work.
    Thanks
    Judy
    I am using JDEV 11.1.1.5

    Sorry for the delay in my response. Here is the code
    <af:inputText value="#{bindings.TotalAirlineCostEst.inputValue}"
    label="#{bindings.TotalAirlineCostEst.hints.label}"
    required="#{bindings.TotalAirlineCostEst.hints.mandatory}"
    columns="#{bindings.TotalAirlineCostEst.hints.displayWidth}"
    maximumLength="#{bindings.TotalAirlineCostEst.hints.precision}"
    shortDesc="#{bindings.TotalAirlineCostEst.hints.tooltip}"
    id="it20" readOnly="false"
    disabled="true"
    styleClass="AFFieldNumberMarker">
    <f:validator binding="#{bindings.TotalAirlineCostEst.validator}"/>
    <af:convertNumber groupingUsed="true"
    pattern="#{bindings.TotalAirlineCostEst.format}"
    type="number"
    maxFractionDigits="0"/>
    </af:inputText>
    thank you,
    Judy

  • Bulleted text with a right-aligned tab with a line leader...

    I am using Pages '09 and am trying to have a tabbed line after bulleted text. I can do this in Word '11...set a right-aligned tab with a line leader then tab at the end of the text and it adds a line. When I tab after text in Pages, it indents the bullet.

    Do two paragraph breaks and then delete the lat one. Now you can do the  tabbed line

  • How to right align text in JTextArea

    Can u plz tell me how to right align text in JTextArea

    what do you mean by align text in java you mean you have a default text that align in the center is it?
    can you please explain ur question clearly
    Thanks

  • XML Import is left aligning my right alignment style with an override, how do I force it to left?

    I'm importing an XML file, using the Import XML menu item, using InDesign CS4.
    In the document I've got a table, with an XML structure in the structure tree, matching in the incoming file. Everything works fine, except that after the 4 "template rows" that I've set up Indesign adds new rows automatically, and for all InDesign auto added rows, InDesign is not using the right alignment that I've set up in the paragraph style applied to the first rows... The style is kept, but overridden by a flush left. (Why?)
    How do I deal with this? I need the right column to go on right aligning
    Best regards, Andreas

    Map tags to styles took care of the problem.

  • How to Right Align the output of amount with currency?

    Hi,
    I have the following SQL query, which basically is the duplication of the SAP standard Item List.  The only difference is, the stock on hand is only for Warehouse 01.
    In the output, I manage to display eg: AUD 1321.00.  However, it is aligned to the center.  Is there a way that I can make it right align like the standard report?  Appreciate your help.
    SELECT T0.[ItemCode], T0.[ItemName], (select T100.OnHand from OITW T100 where T100.ItemCode=T0.ItemCode and T100.WhsCode='01') as 'InStock',T0.[CodeBars], T1.[ItmsGrpNam], T2.[FirmName], T0.[InvntryUom],
    ('AUD'+ replicate(' ',16-len(T0.[LstEvlPric])) + Convert (char(18),(cast ((round(T0.[LstEvlPric], 2)) as decimal(16,2))))  ) as 'Last Eval Price', (T0.[LastPurCur]+ replicate(' ',16-len(T0.[LastPurPrc])) + Convert (char(18),(cast ((round(T0.[LastPurPrc], 2)) as decimal(16,2))))  ) as 'Last Pur. Price',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=1 and T200.ItemCode=T0.ItemCode) as 'L 1',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=2 and T200.ItemCode=T0.ItemCode) as 'L 2',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=3 and T200.ItemCode=T0.ItemCode) as 'L 3',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=4 and T200.ItemCode=T0.ItemCode) as 'L 4',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=5 and T200.ItemCode=T0.ItemCode) as 'L 5',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=6 and T200.ItemCode=T0.ItemCode) as 'Price List 6',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=7 and T200.ItemCode=T0.ItemCode) as 'Price List 7',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=8 and T200.ItemCode=T0.ItemCode) as 'Price List 8',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=9 and T200.ItemCode=T0.ItemCode) as 'Price List 9',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=10 and T200.ItemCode=T0.ItemCode) as 'Price List 10'
    FROM OITM T0  INNER JOIN OITB T1 ON T0.ItmsGrpCod = T1.ItmsGrpCod INNER JOIN OMRC T2 ON T0.FirmCode = T2.FirmCode

    Thanks. 
    But, does that mean the the right alignment in SAP Item list was done through UI? 
    Another question is:
    Normally, in an SAP query, when click Ctrl + left click the mouse at the bottom, I can see the total.
    However, with the query that I have created, it seems to cut off the first number.  Eg: The total should be AUD 231,123.00, but it is showing me AUD 31,123.
    Can you see how I can fix that?

  • How To Right Align Images In A Cell?

    I am a very amateur (i.e. occasional) web site developer using Dreamweaver CS3 and would be very grateful for any advice on the following.
    Several years ago I put together a very simple one page web site using HTML 4.01 transitional and consisting of a single table (width=100%) with several rows. This web site is number one in Google for it's keywords, takes lots of hits every week and because of it's simplicity and the version of HTML used displays well in most web browsers.
    The top row of the main table contains a logo which is displayed left-aligned. The web site owner has given in three more images which he would like to go in to the same row but right-aligned. Could anyone point me to info on how to do implement this very simply, preferrably without CSS (although I have a feeling I will probably have to use CSS in the end).

    ...or you could just modify the <td> tag in your stylesheet: td { text-align: right; }
    Of course that would affect all the <td> tags throughout your document or your site, depending on where your stylesheet is (embedded in the head of your document or in an external css file). So, mostly contextual selectors are used to specify which <td> tags your want to modify. For example,
    #content td { text-align: right; }
    will modify only the <td> tags in the content section.
    With this method, you do not add any markup to your <td> tags in your html document, so your code remains uncluttered.
    Also, the align attribute is still frequently used with the <td> tag. For example, <td align="right">. This attribute is deprecated and will not validate with a strict xhtml doc type. It's not a great sin to use it, but keeping up with standards is a good goal. Again, it adds unnecessary markup to your document. Presentation should be handled with css.

  • Adobe Reader - how to add page numbers with the free version?

    Hey guys,
    Imagine I've got a PDF file and I want to create a new one by selecting some pages out of it. I know this is simply possible by using the PDFcreator but I want to add page numbers. As far as I know this is not possible with the free version of Adobe unless I would add the page number on every single page by using a text box. I want to make different catalogs from the PDF so the page numbers are really necessary. Have you got any idea how to solve that issue? You know that's pretty much the only thing I need to add which means it's not worth buying the Pro version. Unfortunately I only got the PDF and I can't work on it e.g. with MS word before I export it. Do you know if there is a way to add page numbers with a free version? There might be an additional free software which allows that?
    Thanks for your support! 

    Thanks for your quick replies.
    I know how to add text page by page. But obviously it's hard to place the numbers on the very same position, is it?

  • How to right align JTextField content

    Is there a way to right align the content of a JTextField?

    In the JDK1.4.2 API for JTextField, the are 7 methods that start with "set...". It shouldn't be to hard to guess which one would be used for right aligning the contents of the JTextField.

  • How to right align s:Label inside a s:controlBarContent ?

    My spark app has a control bar at the top and i want to right-align a label inside it so my button bar is on the left and my label is on the right. I tried using the 'horizontalAlign="right"' which works find inside a s:panel but not inside a s:controlBarContent. Does anyone have any idea how to achieve this please? Also, the flash builder 4 ide won't let you move the label over in design mode either...
    Thanks for your help,
    Regards,
    Mark.

    I figured it out myself. I added an s:Hgroup around my label and set width="100%" and horizontalAlign="right" you need to set the width to 100% otherwise you're just right aligning within the actual width of the component (which is pretty useless eh?).
    I hope this helps someone else too.
    Regards,
    Mark.

  • How to right align the buttons in JOptionPane?

    Hi,
    I am using JOptionPane in my code.
    I want all the default buttons that are created by any of the JOptionPane methods (e.g. JOptionPane.showMessageDialog()) be right aligned. Currently all the buttons are shown center aligned.
    Here is the only code that I have to display the dialog:
    JOptionPane.showMessageDialog(getInstance(), msg, "Deprecated components", JOptionPane.WARNING_MESSAGE);
    Can someone tell me how to achieve this?
    Regards,
    ParagJ

    Build your own JDialog

  • How can I align mask with object in Y axis?

    Hi
    Can anybody help me? I want to put small band on the upper arm of man in the scene, he is walking from right to left, I put my image in upper layer and made rectangle band and animated it with his arm but the problem is that I cant align the band with arm in Y axis, because of that there are some small tremors in the band, how can I define exact point on the arm and align my mask with it?
    Appreciate any help in advance

    ^ Yep, Mylenium is right. There are two ways to do things - the easy way and the hard way. The easy way always involves thinking things through and establishing what you want before you shoot. Can you shoot with the band in place? If not, can you add tracking markers to the arm to facilitate adding the band later?
    The hard way occurs when you have no choice and the work has to be done after the shoot. And Mylenium is dead right - before computers, EVERYTHING was done by hand, manually checking frame by frame until animations were correct. If your footage does not have the adequate preparation or detail for a computer to track, and you're unable to reshoot, the only option is to animate manually, check, fix, re-check, fix etc.
    The Motion Tracking Workflow section of the manual is an excellent introduction:
    http://livedocs.adobe.com/en_US/AfterEffects/8.0/index.html

  • How to right-click, open with, applescript

    how would I modify the following code in such a way that I can run it from the right click of a folder and choose 'open with' and select my script/application? I want to run the script from the folder rather than having to run the script and select the folder.  I want to use open with because programs like Path Finder and Fork  Lift do not show the services submenu.
    set this_folder to (choose folder with prompt "Pick the folder containing the images to process:") as string
    tell application "System Events"
        set these_files to every file of folder this_folder whose name does not start with "." and (file type is "TIFF" or file type is "JPEG" or name extension is "tiff" or name extension is "tif" or name extension is "jpeg" or name extension is "jpg")
    end tell
    repeat with i from 1 to the count of these_files
        set this_file to (item i of these_files as alias)
    end repeat

    the easiest way to do this might be two convert this to an automator service - open automator, choose Service, tell it to receive the selected folder(s) in the Finder, then add a Run Applescript action.  You'll need to modify the script slightly:
    on run {input, parameters}
              repeat with each_item in input
                        tell application "System Events"
                                  set these_files to (every file of folder each_item whose name does not start with "." and (file type is "TIFF" or file type is "JPEG" or name extension is "tiff" or name extension is "tif" or name extension is "jpeg" or name extension is "jpg"))
                        end tell
                        repeat with i from 1 to the count of these_files
                                  set this_file to (item i of these_files as alias)
                        end repeat
              end repeat
              return input
    end run
    but after you've saved it you can access it from the Services submenu of the contextual menu

  • How to replace old numbers with new mavericks version of numbers

    Thanks to another thread, I have found the new versions of numbers, pages etc. in applications, but how do I get them to replace the old versions in the desktop?

    Good call since Apple dumbed down the new iWork apps to make them compatible with their iOS counterparts.
    See
    http://www.betalogue.com/2013/10/24/pages-5-disaster/
    https://discussions.apple.com/thread/5468056?start=0&tstart=0 and
    http://9to5mac.com/2013/10/25/new-iwork-ilife-apps-go-for-simplicity-upset-power -users-all-over-again/#comments

  • How to generate random numbers with a known distribution of f(X)=(8X^2 + 1)*Exp( -X^2 )

    Dear All,
    I need to simulate a random number generator which can generate numbers X with the probability distribution of 
     f (X) = ( 8X^2 + 1)*Exp ( -X^2 ).
    This distribution is not a common distribution.
    I have searched a lot, but I still do not know how to realize it.
    Any help on this topic would be highly appreciated.

    Make a lookup table of the integral of your function (normalized to 1)
    Use the rectangle random generator and pipe that value through the lookup table, scale it ... voila.
    Greetings from Germany
    Henrik
    LV since v3.1
    “ground” is a convenient fantasy
    '˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'

Maybe you are looking for

  • I want to sync IPhone 5 with itunes, but I can't upgrade itunes nor mac os.

    I just got the iPhone 5 and I would like to sync it to my itunes to upload music. However, apparently I need to buy the snow leopard os for $200 to do so. I am not willing to pay $200 just to upload music on my phone. There has to be another way to d

  • Need info on data retrieval

    1.I have an internal table <b>it_vbak</b> with fields <b>vbeln & auart</b> 2. Select-options: <b>s_auart</b> for <b>vbak-auart</b> 3. I need to retrieve data into <b>it_vbak</b> with the following condition :   VBAK-VBELN = VBFA-VBELV and   VBFA-VBEL

  • Table for "Budget planning : Cost Center"

    Hi Gurus, can anyone pls tell me table for "Budget : Cost Centre" . We create budget with respect to cost center in KPZ2/KPZ3 but i am unable to find out in which this data can be found. Pls tell me the table to retrieve the data. Regards

  • Why can't I reinstall Reader ?

    I am having trouble in installing Reader.  I always had it but was having problem in reading anything.  I removed it and tried to install by downloading again.  But it is not completing installation as it comes back with an error message about runnin

  • Agents of a PCR waiting for Approval

    Hi All, I have a PCR that is Waitiing for Approval. How can i find agents for this PCR ? I have the PCR number. Any hints ???? Regards, Radhika.