String to double conversion, but keeping leading zeros?

Hopefully a simple one for you gurus,
double theValue = Double.parseDouble(aString);works fine, but the input string is say, "08.00", then theValue = 8.0, I want 08.00, how would I go about implementing this?
tia.

You will get ur question answered at the following webpage:
http://java.sun.com/docs/books/tutorial/java/data/decimalFormat.html
--DM                                                                                                                                                                                                                                                                               

Similar Messages

  • Help keeping leading zero String- Long

    Hello
    I wonder lets say I have a String "09090" how do I convert this String to a Long and keeping leading zero so the Long is 09090?
    /D_S

    Numeric types like Long (or long) are numbers, not strings, so they have no formatting notions like leading zeroes. If you want to maintain the string "09090" keep the string around, even if you have to parse it as well. By the way, you forgot to describe what your goal is, what you are trying to do and what it has to do with leading zeroes.
    One more: Why does this print false?
    System.out.println(07070 == 7070);Hint: this generates a compile-time error:
    System.out.println(09090 == 9090);

  • How to keep leading Zeros in a CSV file

    Hi All -
    I am trying to keep leading zeros in CSV file. Ex. I need 00001 but not just 1. I tried formatting the cells but not getting saved. Any advise please.
    Thanks.

    Dear Super Man  ,
    Try using ALPHA Conversion Routine
    ALPHA Conversion Routine
    The ALPHA conversion is used in the BW system for each presetting for character characteristics. The ALPHA conversion routine is registered automatically when a characteristic is created. If you do not want to use this routine, you have to remove it manually.
    The ALPHA conversion routine is used, for example, with account numbers or document numbers
    For more details
    http://help.sap.com/saphelp_nw04/helpdata/en/9b/f9c18f5a07f0459127e9676ae22a54/frameset.htm
    Hope it helps
    Regards
    Bala

  • Keeping leading zero intact  in mail attachment

    Hi All,
    I am sending the excel document into recipients mail id but the leading zero's in the data get truncated.
    I have read so many posts in the forum but did not find any answer to get this done. Some trails i did as follow:
    1. Adding  apostrophes ( ' )  doesn't satisfy my requirement.
    2. Data is good before passing it to mailing function module.
    3. All function module i have tried like SO_NEW_DOCUMENT_ATT_SEND_API1, SO_DOCUMENT_SEND_API1 etc.
       None of them satisfy my requirement.
    Can someone tell  the exact solution?
    Thanks in advance.
    Rudhir Bhaskar

    That's not an SAP email issue though.  I'm sure you'll find that if you open the sent file from a text editor, either from the email client directly or after saving it, that the leading 0's are intact.  Excel is simply interpreting the field as a numeric field upon opening and dropping them.  You need to run the text import wizard and specify the fields as text in order to keep them.

  • Convert hex to Decimal and keep leading zeros..

    Hi,
    I hope you can help?
    How to convert hex to Decimal and keep leading zeros
    I read 002C, hex, and I want to convert it to 0044 decimal.
    sscanf (MyNum, "%4x", &DecNum); will only give me 44.
    It have been working up till I started to get leading zeros.
    We will always have a 4 digit hex input in a range
    We must have the leading 00 in this case.
    How is this best done?
    Thanks for the help
    Simon
    Solved!
    Go to Solution.

    Hi,
    I don't really understand your problem. Is this stuff what you need ?
    int main (int argc, char *argv[])
    const char MyNum[] = "002C";
    int DecNum;
    sscanf (MyNum, "%4x", &DecNum);
    printf ("%04d", DecNum);
    getchar ();
    return 0;
    "0044" appears on standard output when printf function executes...

  • Keeping leading zeros

    I have a series of reports that use Account segmentations that are based on a string of numbers. Unfortunately some of these strings of numbers have leading zeros. (eg. 0023, 0123)
    When the reports are downloaded to excel these leading zeros are lost. Any words of wisdom on how to keep these leading zeros in the report when downloading to excel?

    How would I put the value into double quotes?
    Would this be done under Edit Column Formula?
    If so, I must be doing something wrong. The current column formula is:
    Campaign."Source Code"
    If I change it to:
    "<Campaign."Source Code">"
    I get the following error.
    [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <Code>: Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: SELECT "<Campaign."Source Code">", Campaign."Campaign Name", Campaign.PICK_0, Campaign.PICK_1, Campaign.PICK_2, Campaign.PICK_3, Campaign.PICK_4, Campaign.PICK_5, Campaign.PICK_6, Campaign.PICK_7, Campaign.PICK_8, Campaign.PICK_9, Campaign.Status, Campaign.TEXT_31, Campaign.TEXT_32, Campaign.TEXT_33, Contact."Contact First Name", Contact."Contact Last Name" FROM "Campaign Response Analysis"
    Please advise.

  • Keeping leading zero of an integer

    Wondering if anyone can help me solve this small problem.
    Here's what I had:
    for(int i=01; i<13; i++) {
       String month = "2003" + i;
       System.out.println(month);
    }This gives me the following output:
    20031
    20032
    20033
    20034
    20035
    20036
    20037
    20038
    20039
    200310
    200311
    200312
    However, I want the output to be:
    200301
    200302
    200303
    200304
    200305
    200306
    200307
    200308
    200309
    200310
    200311
    200312
    Then I tried this:
    String year = "2003";
    String month = new String()
    for(int i=01; i<13; i++) {
       if(i<10)
          month = year+"0"+i;
       else
          month = year+i;
       System.out.println(month);
    }The code above gives me the results I want. However, I'm thinking that there has to be a better way to do this. Is there anyway to increment the variable i and kept it two digits? I mean keeping the leading zero until it gets to the number 10? Any ideas?

    the previous poster is right. It's also a little odd how you have things setup, in that you're expressing dates with an unusual approach (most people would use Date or Calendar), but, if you want to keep like you have it, I think this might be the easiest solution:
    int date = 200300;
    for (int i = 1; i < 13; i++ ) {
      System.out.println(date + i);
    }

  • Alpha-convers. in BW but no leading zeros from source system

    Hello all,
    I want to load customer data via XML. The data are delivered via XI every night in a delta-queue in BW. From the delta-queue the data gets loaded into an ODS.
    From the source system I get the customer number with 6 characters, but in BW I have a alpha conves.Routine in the InfoObject 0SOLD_TO and 0CUSTOMER.
    How can I fill in leading zeros to the values? Do I have to do this in the InfoSource setting or in the update rule?
    Any ideas would be great.
    Thanks upfront and Best regards,
    Stefanos from Munich/Germany

    Hi,
    Try checking the option in the transfer rules. Aganist the Info Object 0Customer you'll have to scroll to right then you can see the check box called conversion . Check that & try loading the data.
    Other than this you'll have to go with the routine.
    Regards,
    SB

  • Export jsp content to Excel -- how to keep leading zero?

    Hi:
    I am trying to export a JSP content to Excel by using
    response.setContentType( "application/vnd.ms-excel" );
    response.setHeader( "Content-disposition", "attachment; filename=pc.xls" );
    it was working great except my jsp has a field whose value consist of leading zero. i.e. 000XXX. Excel strips the leading zero, but I would like to keep them. Please advise.

    hi Chang,
    Can you please check my thread http://forum.java.sun.com/thread.jspa?threadID=737238&tstart=0
    I think you might know the answer since it is similar functionality but for text files.
    Thanks !

  • Keeping leading zeroes in flat file

    I am loading data from a flat file to a DSO.
    One of the columns in the flat file is data type CHAR with a length of two. The data values will be either 01, 02 or 03.
    When I load the data, the leading zeroes are dropped. Thus, I see 1, 2 and 3 in my DSO. How can I prevent this happening?

    Hi,
    Right Click on that column in Excel file and Formate Cells >Custome> Under Type give "00" and then give the values in column like 01 , 02 .... and save as .csv and close it, immediatly load it, DON"T OPEN FILE, because , if you open it will reset to 1, 2... SO again you need to Right click.....and formare cells..
    Thanks
    Reddy
    Edited by: Surendra Reddy on Jun 24, 2010 4:28 PM

  • How to keep leading zeros using SAP_CONVERT_TO_XLS_FORMAT

    my leading zeros  drop when download using FM-SAP_CONVERT_TO_XLS_FORMAT, how to fix it?

    Hi,
    You can try as below.
    Let's for the 10 digit numeric field, using the function module CONVERSION_EXIT_ALPHA_INPUT, you can get the 10 digit number with leading zeroes.
    Now if you declare the char of 10 in length field in the internal table will be replaced with the above value.
    Now it will be downloaded as required.
    Regards,
    Nishant Malhotra

  • HELP: String to double conversion?

    Hello,
    I want to convert a String to a double, and then use this double for a calculation. The conversion seems to be ok, but I get an error with the calculation... Please HELP!
    A part of my code:
    double angle;
    Double converted_angle;
    angle=jTextField2.getText();
    converted_angle= Double.valueOf(angle);
    double theta = cos(Math.PI/180*converted_angle);
    ERROR: "operator * cannot be applied to double,java.lang.Double"
    Thanks in advance.

    This is happening because you want to multiply a Double object, instead of a double value. Do this:
    Double converted_angle; should be double converted_angle;
    converted_angle= Double.valueOf(angle); should be changed to converted_angle = Double.parseDouble(angle);
    angle should probably be a String.
    check this link for your options:
    http://java.sun.com/j2se/1.4/docs/api/java/lang/Double.html

  • LV RT - String to double conversion

    Hello,
    I want to convert a string to a double on my Real Time device (PXI-8101. When I use the "scan value" or "Fract/Exp String To Number Function" VI the numbers after comma dissapear. This does not happen on the Host (PC). 
    So for example on the host vi, the string "2121,3" gives the number 2121,3. If I do the same thing on the Real Time, the string "2121,3" returns the number 2121. 
    How can I fix this?
    Thanks in advance,
    Regards,
    Dries
    Solved!
    Go to Solution.
    Attachments:
    String2Number.vi ‏7 KB

    Hello,
    Thanks for the reply, but scan from string also does not return the correct number on the RT device. The VI returns the number after comma as the remaining string. Any other suggestions?
    Best regards,
    Dries
    Attachments:
    String2Number.vi ‏8 KB

  • How to keep leading zeros in numeric Keynote entries?

    When I try to enter numbers that start with zeroes in a table, Keynote removes the zeroes. For instance, I type 007 and it gets "corrected" to 7. Also, for instance, when i type false in lower case, it gets changed to FALSE.
    How do I stop this? I found the Auto-correction tab in Preferences, but everything is unchecked there except for the things that deal with email and hyperlink underlining.

    Ok, naturally I found it after I posted the question. I go to Table in the inspector window and change Cell Format from Automatic to Text.

  • Leading zeros from Adobe form web service data connection

    I created a web service for BAPI_PRODORD_GET_DETAIL and used it as a data connection in an Adobe form. When executing the connection using request parameters of:
    Number = [Production Order #]
    OrderObjects.Operations = 'X'
    no production orders are found.
    I debugged and discovered the BAPI only found production orders when the Number importing parameter contained padded leading zeros. After searching the forums, I suspect (1) I have the wrong field type and / or pattern for the production order number input field or (2) SAP Note 1050826 may apply.
    Does anyone have suggestions on which field types and patterns to use? I have tried each of Text, Numeric, and Decimal. When using Numeric, I set the data format to Float instead of Integer. I tried data patterns such as: num , the data displays with leading zeros but does not pass to the BAPI with them.
    I was also thinking a Formcalc or Javascript may be the solution.
    Livecycle version: 8.1.2
    Component SAP_APPL: 603 (for SAP note relevancy)
    Thank you,
    --- Scott

    Hello,
    maybe it would be the fastest approach here to work with the value as a string and check the length of the "string" and if needed add some leading zeros. You may try some validations, so the value entered by the user is denied if not in the respective format.
    For a smooth start with scripting start here:
    http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_basics.pdf
    http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf
    Regards, Otto

Maybe you are looking for

  • Pages 5.5 is now available in the App Store.

    Start the testing! And let us know what works and what still doesn't. Peter

  • Problem client/server with GUI

    I have a problem with a project im working on. I have a main method that has an infinite loop but before it enters the loop, i draw the GUI. I put a simple print statement and found that it goes through the loop once. Can someone help me to figure ou

  • How to correct sql to populate parent(id) in curr_mgr_id

    HI ALL, SELF_REFERNTIAL_INTEGRITY DEFINED ON EMP_HCHY ID IS A SEQUENCE GENERATED NUMBER CREATE TABLE EMP_HCHY(ID NUMBER PRIMARY KEY, CURR_MGR_ID NUMBER REFERENCES EMP_HCHY(EMP_NO), EMP_NO VARCHAR2(20), TITLE_NM VARCHAR2(20)) CREATE TABLE STG_HCHY(EMP

  • Opening CR2 (Canon 5D RAW files) in Photoshop CS

    hello, i have a canon 5d and am trying to open them with the original Photoshop CS. Is this impossible? Is there no plug-in that is compatible with this older version and the CR2 files? thanks for your help.

  • NPE while starting Node Manager in SOA 11.1.1.5

    I have installed SOA Suite 11g (11.1.1.5) as per Oracle Quick Start Guide for SOA Suite 11.1.1.5. I start the database and Weblogic admin server. When I try to start the node manager, I am getting following error: 1 Nov, 2011 9:23:28 AM weblogic.node