\b Formatting number with a pattern?

I am trying to format a number according to the given format by the user. For eg: if the given number is
1234 and the given pattern is ###.# then my output should be 123.4 Now this is a simple pattern . The input pattern could be even like this ###,##,##.##.

The DecimalFormat won't change the value of what you give it, just format the value. One way to do what you want is to convert your number to a StringBuffer, then just add a decimal point where ever you want. This won't give you a great deal of flexability, but will solve the problem that you've given.
long dval = 123456;
StringBuffer sb = new StringBuffer(String.valueOf(dval));
sb = sb.insert(sb.length()-2, '.');
System.out.println(sb.toString());This code can easily be modified to be turned into a method that will take the value and the number of digits after the decimal that will return a String (or double or long) with the new value.

Similar Messages

  • Formatting number with f:convertNumber

    Hi
    I have to display telephone number and fax numbers as 818-765-1234 format.
    I have the data as Long type in my backing bean and am trying to use the <f:convertNumber> to display the data.
    Do I need to implement a custom convertor or does JSF provide out of the box convertor for my purpose.
    Please respond.

    see tomahawk components. Also Shale components.

  • Format-number doesn't work with XSL and DW preview

    Hi All
    I'm creating XSL files to transform XML into HTML. However,
    the number formatting doesn;t seem to work in Dreamweaver. For
    example, if I specifiy:
    format-number(price,'$###,###.00'), I should get $7596.99. I
    actually get 7596.990000000001 in my Preview (no currency symbol,
    too many decimal places). If I do the same thing in another XSL
    editor (Xseleerator) I get: $7,596.99.
    This is REAL PAIN, as every time I do anything with number
    formatting, I need to open the XML and XSL in another product just
    to check the formattng.
    Can anyone shed any light on this?
    Thnaks
    Mark

    Try to declare the variable out side of the region
    <script> var tp1;</script>
    <div spry region ... >
    tab panel stuff
    <script type="text/javascript">
    tp1 = new Spry.Widget.TabbedPanels("tp1");
    </script>
    </div>

  • Format-number not working for me with preview to excel

    Hi,
    I have a report with 8 fields across within a table.
    Each field is formatted in the same way, with format-number like this (there are 8):
    <?format-number:total-year-remaining;’PT999G999D99’?>
    (that's the type-your-own form-field help text in the word template).
    When I preview the PDF, the data looks fine (8 cells shown below):
    .00 (.10) (.10) .00 (.50) (.50) (.60) (.60)
    But when previewing to Excel, there are two problems:
    1. Only the data in the last field (the 8th one) is formatted with the oracle mask:
    (.60)
    But upon closer inspection, there are two blank spaces after the number in that cell, and the value itself is treated like a string, e.g. '(.60) '. In fact if I ask excel to format this cell like a number with currency and two decimal places, in won't do it because of trailing spaces. Its just not a number to excel at that point. Probably the ('s don't help things either.
    2. The data in the first seven fields in excel are numeric, and I can format them in excel as currency, but I wanted XMLP to handle this, not the excel user.
    The bottom line is this: I want both PDF and excel output. I want both forms to have the fomat mask applied correctly. And I want excel to treat each cell as a number. Is this possible?
    Thanks
    Adam

    Anatoli,
    Hello!
    I don't know if my situation is the same as yours, but after a lot of head-scratching, forum searching and template rebuilding, I finally figured out my problem.
    I had one column that no matter what I did kept appearing in Excel as text. I'd format it to Number in Excel and nothing. When trying to sum the column, Excel would not recognize any of the values as numbers. I even did the reformatting on the XML Word template to number, and the currency format that Adam mentions. Still no go. The $ and ',' appeared, but column still formatted as string.
    I just finally noticed Adam's mention of the 2 extra spaces at the end of the numbers and sure enough mine was doing the same thing. Take out the 2 spaces and voila! Number!
    Every time I redid my template in Word (07 and 03), I used the wizard. (Add-ins>Insert>Table>Wizard) walked through the steps, not really changing anything. Then I would preview and the spaces would be there. The column that I was having problems with was the last column of the table, which would get the text 'end G_ASSIGNED_CC' inserted in after the field name - separated by 2 spaces. Once I took out these two spaces, so the column now shows 'COSTend G_ASSIGNED_CC', it worked fine in Excel - all numbers.
    Hope that helps someone out there as I was having a heck of a time finding anything (solutions anyway) on this.
    Thanks,
    Janel

  • Hide number (or format number) on Oracle Report with Barcode

    Hi al !
    i have done a example about print Barcode on Oracle Report
    with help link :
    [http://download-west.oracle.com/docs/html/B10602_01/orbr_barcode.htm|http://download-west.oracle.com/docs/html/B10602_01/orbr_barcode.htm]
    However
    I want to hide number under Barcode images or Format number !
    Ex:
    |||||||||||||| --> images barcode
    1234567 --> number barcode
    i want : hide : "123456" or format it : "123.456"
    Thanks !

    Hello,
    The Image is generated by the java code in oraclebarcode.jar
    It is possible to "hide" a part of the image by puting an object ("rectangle" for example ) over the part of the image you want to hide.
    Regards

  • Format a number with leading ones

    How do I format a number with leading ones or twos?
    This is what I'd do to format a number with 8 leading zeroes:
    String.format("%08d", 160)But, if I do the same with 8 leading ones, it does not work the way that I expect:
    String.format("%18d", 160)I'd appreciate your help.
    Thanks.

    933581 wrote:
    >
    What are you expecting?
    >
    I expected that "%18d" would pad with 1s.You assumed
    mmm I just thought that while "%08d" pads with 0s, the same would happen if I used "%18d" to pad with 1s.But if you would have looked at the javadoc of that method you would have very quickly known this was not the case and you wouldn't even had to create this thread. Why operate on guesswork when it is so easy to know reality? :(

  • Outlook 2007 phone number format incompatible with...

    I use MS Outlook to organise my E-mail, Calendar, Tasks, Contacts, Notes, etc.
    With Contacts, the Outlook format is for example:
    +00 (000) 0000000
    Nokia PC Suite can recognise the above number while Nokia Ovi Suite cannot.
    For example, in PC Suite, in Messages, the above Outlook format is recognised and assigned the correct name and other details.

    outlook and the phone does synchronise, that is, the contacts from outlook synchronises with the contactsin the phone. the issue i have is with the Ovi Suite Messaging.
    there are two types of contacts and the number format:
    1. contacts i added using the mobile phone and has the number format:
    +000000000000
    2. contacts i added using Outlook and has the number format:
    +00 (000) 0000000
    in Ovi Suite Messanging, the names of the contacts using method 1, those added using the phone, appear. when the person sends a message, the software recocnises the number, associates the name and messaging thread
    the contacts added using method 2, on the other hand, are not recognised by the software, and therefore appear as the number (+000000000000) rather than the name.
    and so i have two messaging threads for every contact:
    1. a thread where i sent the text, because i used the number from Outlook. and its all sent messages
    2. a thread where i received the text because the Ovi Suite does not recognise the number +000000000000 because the number in the contact that was from outlook is +00 (000) 0000000
    with Nokia PC Suite, the software associates the number with the contact from Outlook. so i would receive a message with +000000000000 and it would assign the correct contact with +00 (000) 0000000
    will this get sorted? i like the concept of the Ovi Suite but its not very user friendly. now im tempted to get either a blackberry or iphone.

  • Problen with the format number on Phone Call and SMS

    Hello everybody, I live in Peru and I bought and iPhone 3g. I have a problem with the sms. I saved a person in my address book. When I received a phone call I could see the person who calls me, but if this person sent me a SMS I couldn't see his/her name.
    In my address book the format number of the person is: 01xxxxxxxxx
    But when I received the sms the format number is: +511xxxxxxxxx
    If I modify the format I could see the contact in the SMS but when he/she called me I couldn't see the contact on the phone.
    Any suggest or idea?
    Thanks for your answers.
    Kind Regards
    Alfredo

    Hello everybody, the solution of my question are in the new iphone software update. When I updated my iPhone with the firmware 2.1 the phone contacts and the sms contacts are the same.
    Thanks for your help.

  • Need formula to take text from one cell, add that to a serial number with leading zeros

    I'm trying to create a spreasdheet cell that simplifies creating videotape Numbers from a job name in cell and appends a serial number with leading zeros, and that would survive an export to EXCEL.
    The result would look like
     A Column
    Job Name
    B ColumnTape #
    Formula needed for B
    ClientName-TapeType-
    ClientName-TapeType-001
    =
    ClientName-TapeType-
    ClientName-TapeType-002
    =
    I've tried using a custom cell format that had the text in front of the (Integer) drag and drop, with three integers and leading zeros.
    That worked, but requires recreating the custom cell format for each client and tape type.
    So, I've used the formula =A2& in order to play around with different things, but haven't hit on something that adjusts for increased numbers and retains the leading zeros.
    I don't mind doing a starter for the first row and then adding +1 in the formulas for the rows below.
    I've done that using the custom cell formats for the first B cell and then using =Bx+1 in the following cells.  It works, but I'm hoping to find something simpler or that can be copied and pasted in multiple rows on one paste.
    Thanks in advance.
    Suggestions much appreciated!
    Ted

    Ted,
    This expression in B will give you the pattern I believe you are looking for:
    =A&RIGHT("00"&ROW()-1, 3)
    Here's a screen shot...
    Jerry

  • 2 Formatting issues with HTML forms

    I have a couple of issues that we can't seem to get past with adobe livecycle designer 7.0. We have an internal form, rendered in HTML, that is emailed between departments, and the data entered is stored in an XML file that is created using the code similar to the following:
    protected void doPost(HttpServletRequest request,
    HttpServletResponse response) throws
    ServletException, IOException
    oOutput = response.getOutputStream();
    try {
    FormServerWithXML fsb = new FormServerWithXML();
    fsb.processForm(request);
    File file = File.createTempFile("Form_", ".tmp", new
    File("d:\\xmlFiles"));
    BufferedWriter(new FileWriter(file));
    out.write(fsb.getXMLString());
    out.close();
    When we use a numeric field and try to format it with any display pattern containing dollar signs, decimals, etc... the xml data for that field isn't being written to the xml file. All of the other fields are being written properly.
    The next issue we're having is that with HTML forms, when we create a multiline text field we are unable to limit the number of characters that are allowed in the field.
    I'm pretty new with this, so please send some advice my way if you have any.
    Thanks,
    Chad

    Thanks Rakhi, but that did not resolve my issue. Below is new out as per the thread suggestion and this is not what I wanted.:
    "<H>Thank you for choosing Enterprise.</> We look forward to seeing you at 9:00 am on Monday,
    November 28, 2011. This message is to confirm you have updated your reservation.
    Following are the details for the updated reservation:
    P.S. Remember us when you're renting in town. Enterprise is always nearby at more than 6,500
    neighborhood locations."
    - shalini

  • Format number not working correctly in XML Publisher Report

    Hi,
    I have requirement to print sum(column1) with number format with commas on the header.
    I tried giving <?format-number:sum(//CURRENT_COST);'99G990D00'?> this formula is sum current cost column and displaying as 140.253.123.00 but i want to display the same as 140,253,123.00
    i even tried <?xdoxslt:xdo_format_number_l(sum(CURRENT_COST),'999G999D99','EN-us')?> but its even giving the same result as  140.253.123.00
    Please let me know if anyone had the same issue.
    Thanks.

    Hi,
    You can't mix the XMLP extended functions (ie anything prefixed with xdofx) with xsl functions (see user guide - Extended SQL and XSL Functions).
    You could look at using the Choose statement or doing a set of IF statements
    ie <?if:CURRENCY='JPY'?>format...<?end if?><?if:CURRENCY...<?end if?>
    If you go with the multiple IF statements you will probably need to use <?if@inlines:CURRENCY='JPY'?> otherwise you will get carriage returns (see IF statements in boilerplate text in the user guide).
    Thanks
    Paul

  • Partition an Advanced Format drive with 4KB sector (for Linux OS only)

    I got a brand new WD 1TB drive, model WD10EZEX, I'm upgrading from an old 500 GB drive with Arch running on it, and I'm going to make a fresh Arch install on it.
    I suddenly learned about all this Advanced Format issue, with the first units "lying" about physical sector size and all that stuff, which started like 2 years ago and I was not aware of.
    I couldn't find a step by step guide to perform the proper formatting for a fresh Linux OS install with 4KB-sector, despite the info is out there scattered in tons of blogs, forums, etc.
    I figured out the steps for my simple setup, and I'd like to know if everything is all right. For the ones who already know the steps, can you please go to the bottom of the post, and tell me if the final setup is all right to start the fresh install ??  I reproduce all the steps hoping that this will help other people in the future.
    I'll use the whole drive only for an Archlinux install, with one partition for the / and another for /home.
    Seems the GPT modern method is the way to go, and the gdisk tool will do the trick. If we are booting from this drive, with GRUB2 in a BIOS system, we must also create a BIOS Boot Partition.
    So, with the drive having no partitions at all, and sda being the device name
    # gdisk /dev/sda
    Command (? for help): p
    Disk /dev/sda: 1953525168 sectors, 931.5 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): 6527769B-B4BC-408C-A45B-D2DAA4036620
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 1953525134
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 1953525101 sectors (931.5 GiB)
    Number Start (sector) End (sector) Size Code Name
    we create the 2 MiB BIOS Boot Partition
    Command (? for help): n
    Partition number (1-128, default 1): 1
    First sector (34-1953525134, default = 2048) or {+-}size{KMGTP}: 2048
    Last sector (2048-1953525134, default = 1953525134) or {+-}size{KMGTP}: +2M
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): ef02
    a 45GB partition to use as /
    Command (? for help): n
    Partition number (2-128, default 2):
    First sector (34-1953525134, default = 6144) or {+-}size{KMGTP}:
    Last sector (6144-1953525134, default = 1953525134) or {+-}size{KMGTP}: +45G
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): 8300
    Changed type of partition to 'Linux filesystem'
    and the rest to use as /home
    Command (? for help): n
    Partition number (3-128, default 3): 3
    First sector (34-1953525134, default = 94377984) or {+-}size{KMGTP}:
    Last sector (94377984-1953525134, default = 1953525134) or {+-}size{KMGTP}:
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): 8300
    Changed type of partition to 'Linux filesystem'
    we can check the setup
    Command (? for help): p
    Disk /dev/sda: 1953525168 sectors, 931.5 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): 6527769B-B4BC-408C-A45B-D2DAA4036620
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 1953525134
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 2014 sectors (1007.0 KiB)
    Number Start (sector) End (sector) Size Code Name
    1 2048 6143 2.0 MiB EF02 BIOS boot partition
    2 6144 94377983 45.0 GiB 8300 Linux filesystem
    3 94377984 1953525134 886.5 GiB 8300 Linux filesystem
    and everything looks fine, we have the multiples of 8 starting sectors, so we write the changes
    Command (? for help): w
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
    Do you want to proceed? (Y/N): y
    OK; writing new GUID partition table (GPT) to /dev/sda.
    The operation has completed successfully.
    now we need to give the / and /home partitions a format, I choose ext4 and ask for a 4096 block size just in case we have a "lying" unit (not my case but I prefer to write down the most general command)
    # mkfs.ext4 -b 4096 /dev/sda2
    mke2fs 1.42.6 (21-Sep-2012)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    2949120 inodes, 11796480 blocks
    589824 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=4294967296
    360 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000, 7962624, 11239424
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done
    and the same thing for /dev/sda3 .
    Check with gdisk and parted that everything is fine, is this all right to start the install ??
    # gdisk -l /dev/sda
    GPT fdisk (gdisk) version 0.8.5
    Partition table scan:
    MBR: protective
    BSD: not present
    APM: not present
    GPT: present
    Found valid GPT with protective MBR; using GPT.
    Disk /dev/sda: 1953525168 sectors, 931.5 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): 6527769B-B4BC-408C-A45B-D2DAA4036620
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 1953525134
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 2014 sectors (1007.0 KiB)
    Number Start (sector) End (sector) Size Code Name
    1 2048 6143 2.0 MiB EF02 BIOS boot partition
    2 6144 94377983 45.0 GiB 8300 Linux filesystem
    3 94377984 1953525134 886.5 GiB 8300 Linux filesystem
    # parted /dev/sda
    GNU Parted 3.1
    Using /dev/sda
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) print
    Model: ATA WDC WD10EZEX-00R (scsi)
    Disk /dev/sda: 1000GB
    Sector size (logical/physical): 512B/4096B
    Partition Table: gpt
    Disk Flags:
    Number Start End Size File system Name Flags
    1 1049kB 3146kB 2097kB BIOS boot partition bios_grub
    2 3146kB 48.3GB 48.3GB ext4 Linux filesystem
    3 48.3GB 1000GB 952GB ext4 Linux filesystem
    Last edited by karamaz0v (2012-12-06 06:39:45)

    Your partitions look fine from an Advanced Format point of view. The test is simple: Are all your partitions' start points, as measured in sectors, divisible by 8? Yours are.
    karamaz0v wrote:what confused me a bit, was that I saw a lot of setups with the BIOS boot partition, and also a 200 MB EFI one. Having a BIOS system, I think I don't need the EFI one.
    Some people do this because they're unclear of their requirements. Others do it because they want to have the option of switching boot modes between BIOS/legacy and EFI. With both types of boot loader installed, you can choose on a boot-by-boot basis which way to start the computer, assuming it supports both boot modes.

  • How to Create a Auto Generated number with some preceding text in Sharepoint 2010

    I am trying to create a auto generated number field in Sharepoint 2010 list item. My requirement is to have the following format number generated when new request is created in Sharepoint using form. Auto generated Ticket ID should be in the following format
    "IR13000" "IR13001" "IR13002"....... Please let me know how to get this done. I tried to use combination of default ID and Characters but its not working for new requests, its only reflecting for existing uploaded requests. I
    am trying this for taking up Ticket requests by filling up some fields in the form. Any quick help is much appreciated.
    Thanx

    Here are the steps:
    1 - Open your SharePoint site in SP Designer 2010.
    2 - Click Workflows and add a List workflow. Associate this workflow on the list where you want the Random Text to be generated.
    3 - Inside the workflow editor, select the Action "Update list item"
    4 -  Select 'Current Item'.
    5 - Click Add.. and select the field which needs to be updated with the Random Text. Make sure this column is not of type "Calculated" type, otherwise you won't see it in the list of the fields within the workflow.
    6 - Click "..." button in the next textbox which will open String Builder dialog box.
    7 - Type IR and then click 'Add or Change Lookup and select ID column from "Field from source". Hit OK.
    8 - It should look like IR[%Current Item:ID%]
    9 - Hit OK.
    10 - Save and publish the workflow. (Please note that currently this workflow is not set to auto run on creating new items. That's because we want to test it at this point of time).
    11 - Go to your list in SharePoint and create a new item. After creating, select the item and click Workflows and then run this workflow.
    12 - You should be able to see the text "IR1" in the designated column.
    13 - Once you see that it's working, go to SPD and set the workflow to run automatically on creation of the new item. Save and publish and then return to your list in SharePoint.
    14 - Create a new item there and you should see the Random value in the column.
    15 - You will also see the column in the New form. In order to remove it, go to List settings > content types > Item content type > and select Hidden for this column so that it doesn't showup in any form.
    Try it and let me know how it goes.
    Thanks,
    Ashish

  • Format Number in XML Publisher

    Hi
    I am developing a RTF template for EXCEL output report. I am trying to format a number value in this report
    <?xdofx:if to_number(QUARTER_QUANTITY) > -1 then QUARTER_QUANTITY end if?>
    in the above line of code how could we format QUARTER_QUANTITY field (i need 9,999, 999 format)
    I have tried both
    format-number:fieldname;’999G999D99’
    format-number(number,format,[decimalformat])
    nothing worked for my.
    Can some one please help me to resolve this issue.
    thanks
    Raj

    Hi Raj,
    Were you able to solve this problem? I am running into the same problem where I want the number to dsiplayed with 2 decimals. When I view the output in Excel format , it cuts off the last zero for eg 18.30 becomes 18.3 If i use any other Output format like HTML trailing 0s are preserved. How do I solve this
    Thanks

  • Problem in Formatting Number in eTEXT template

    Hi All
    We want to format the payment amount for check in the eTEXT template.
    We want a number with 2 digits after decimal point and a comma before 3 digits to the decimal point.
    We tried using
    Number, ####,###.##
    But for the data 135 it is printing 0000135.00, But we want it in 135.00
    Similary for data 1356.7, we would like to have 1,356.70
    I tried with some trial and errors, but no luck.
    your help is appreciated.
    Thanks & Regards
    Naga

    it should work,
    I would like to see your template,
    drop me xml and template to my id , its in profile.

Maybe you are looking for

  • How do I use 'find my iphone' on my pc?

    I just upgraded to iSO 5, I got the Find my iphone app, have the lastest icloud on my pc, have the app on my iphone and can't seem to use it.  The icon shows up on my phone, and is on. The icon is in my Apps folder in itunes. I have read ALL the dire

  • Image size and format for IMovie

    I am trying to make a short stop motion animation in IMovie. I have made my images in Adobe illustrator. I transfer the images into IMovie as JPEGS.the images, which are basically line drawings, look sharp and clean but as soon as you watch them as m

  • How to Upload Price details for a catalog in CCM 2.0

    Hi all, I am successfully uploaded the details like schema, Category, item contents(ie Product id, supplier part no, Base unit, Order unit, Description). I am not able to upload the price and currency details of the item. The format which i used is s

  • How to procession session in foreground and errore mode from the program.

    hi ALL i have a requirement in wich i had to create a session and procession the sesion in foreground or back ground from the program it self (with out going to SM35) argent can any body answer to my question, please reward gauranty. thanks in advanc

  • How do I get my music off of my Ipod onto my Iphone?

    I need help