Java code number formatting

Wonder if you could help me, I am a student and I've written an applet program for an assignment that creates an array of objects, each object has 3 elements. A string, another string, and a float. The float is multiplied with an integer in another method, and the resulting outputs a number which is the price of a "book". I need to format that result to show two decimal places, but when there is only one number I just get that number instead of the zero, for example if the result is 42.50 I just get 42.5. How do I get that last zero to show up, could you show me an example line of code for this number formatting? Thanks.
Tyler

Try to compile and see this piece of code.............I hope it meets ur requirement.
import java.math.BigDecimal;
public class Dec {
     public static void main(String s[]) {
     int decimalPlaces = 3;
     int a = 10;
     double b = 100.20000;
BigDecimal bd = new BigDecimal(a+b);
     // Truncates the big decimal value.
     bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
     String string = bd.toString();
     System.out.println("ANswer"+string);
Regards,
Aru

Similar Messages

  • Is this a bug in Java for number format ?

    Hi,
    I found somethings strange when I trying to use NumberFormat.
    Here are the sample code:
    --- Sample Code start ---
    import java.text.*;
    public class TestNF {
    public static void main(String[] args) {
    double num1 = 10.5;
    double num2 = 10.55;
    NumberFormat nf1 = NumberFormat.getInstance();
    NumberFormat nf2 = NumberFormat.getInstance();
    nf1.setMinimumFractionDigits(0);
    nf1.setMaximumFractionDigits(0);
    nf2.setMinimumFractionDigits(1);
    nf2.setMaximumFractionDigits(1);
    System.out.println(nf1.format(num1));
    System.out.println(nf2.format(num2));
    -- Result start --
    10
    10.6
    -- Result End --
    --- Sample Code end ----
    Since 10.55 is rounded up to 10.6, therefore it should be the same behavior that 10.5 is rounded up to 11.
    Please correct me if I m wrong.
    Version:
    java version "1.6.0_21"
    Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)
    ** Added result from my sample code & java version
    Thanks and Regards,
    Jin Keat, Saw
    Edited by: 903151 on Dec 19, 2011 4:55 PM

    jverd wrote:
    903151 wrote:
    Since 10.55 is rounded up to 10.6, therefore it should be the same behavior that 10.5 is rounded up to 11.
    Please correct me if I m wrong.And this is exactly what I get when I run your code under Java 1.6 on Windows 7.
    :; java -version
    java version "1.6.0_29"
    Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)
    Also, this has nothing to do with Generics.
    Hi,
    Sorry for my poor English.
    Do u mean by running my sample code, you got 11 instead of 10 ?
    Please advise which is the correct forum/thread.
    Many thanks.
    Regards,
    SawJK

  • Java number formats?

    Hi.
    I am writing a program which contains a simple division code. The operation divides a word's frequency in a file by the number of words in that file. This is a code strip
    wordCount = wordsInFile(file2); //number of words in file is obtained from a static method
    String w = wordFreq.get(i).toString(); // I get the frequency of the word from an array list
    double wf = Double.parseDouble(w);
    double normalFreq = wf/wordCount;problem is that sometimes this program produces numbers like this : 8.025682182985554E-4
    I have no idea what this means and how to fix it. Is there a specific number format that I should use to avoid this?
    Thanks!
    Message was edited by:
    Yorae

    Hi.
    I am writing a program which contains a simple
    division code. The operation divides a word's
    frequency in a file by the number of words in that
    file. This is a code strip
    wordCount = wordsInFile(file2); //number of
    words in file is obtained from a static method
    String w = wordFreq.get(i).toString(); // I get the
    frequency of the word from an array list
    double wf = Double.parseDouble(w);
    double normalFreq = wf/wordCount;problem is that sometimes this program produces
    numbers like this : 8.025682182985554E-4
    I have no idea what this means and how to fix it. Is
    there a specific number format that I should use to
    avoid this?
    Thanks!
    Message was edited by:
    YoraeTake a look at java.text.DecimalFormat
    double normalFreq = wf/wordCount;
    DecimalFormat df = new DecimalFormat("#.##");
    String output = df.format(normalFreq);
    System.out.println("The formatted double is " + output);This should truncate any digits after the second decimal place (I think it rounds it for you but I havent checked).

  • How to get personnel number of the user in the wd java code in Leave reques

    Hi all,
    we are using the standard Leave Request Applicatin ESS.
    can any one please tell me how to get the personnel number of the user in the WD java code?
    cause i have pass the pernr number to a bapi and get the details.
    please help me its urgent.
    thanks in advance.

    Hi Madhu,
    Create a model for the particular bapi in wd java and acess it in your component. Then pernr parameter will be available in the context and u can pass value for the parameter (pernr) to the model and get the output.
    If you hav any doubt, please let me know.
    Regards,
    Jithin

  • Formatting java code in html [code]

    Hi ppl,
    any suggestions how does code tag(formatted java code) works in this site?
    thanks in advance.

    thanks for looking at my post.
    Sorry the question was not too explanatory. I am trying to have same functionality on my jsp page so that i can put formatted java code on jsp page.
    So what I am after is any hints or links, for how to achieve this.

  • Need Port number for active Host name using java code

    Hi All,
    I have tnsnames string and I know one of the following Host is working  say Primary-host .
    DESCRIPTION =(ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = Primary-host)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = Secondary-host)(PORT = 1522)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORA112DB)))
    Could you please help me to get Port number of only primary Side ?. This needs to do because we cannot get port number using any oracle query.
    Thanks in advance
    JPrashant

    You may get client's host IP with
    select sys_context('USERENV','IP_ADDRESS') from dual;
    You may get client's port with
    SELECT port FROM v$session where username = user;
    To get connection port you should issue OS command (*nix) like
    netstat -n | grep <client_ip>:<client_port>
    tcp 0 0 192.168.1.1:1521 132.168.1.2:65432 ESTABLISHED
    To run OS command (keeping in mind all possible security consequences) it is possible to write C, java code.
    Example -- http://www.oracle.com/technetwork/database/enterprise-edition/calling-shell-commands-from-plsql-1-1-129519.pdf

  • Color names in Java code format.  Looking for the 216 safe colors.

    Color names and associated values are available in HTML format; I am looking for such a list in Java code.
    thanks for any help.

    // Since I could not find it, I pasted it up myself.
    // Since I think it is useful and cool, I am sharing it.
    import java.awt.Color;
    Java class of the standard non-standard "safe" browser colors.
    View and choose colors grouped by color at
    <http://halflife.ukrpack.net/csfiles/help/colors.shtml>
    or others.
    Colors in this alpha ordered list are presumed to correspond.
    public class Colors {
    public static final Color AliceBlue = rgb("F0F8FF");
    public static final Color AntiqueWhite = rgb("FAEBD7");
    public static final Color Aqua = rgb("00FFFF");
    public static final Color Aquamarine = rgb("7FFFD4");
    public static final Color Azure = rgb("F0FFFF");
    public static final Color Beige = rgb("F5F5DC");
    public static final Color Bisque = rgb("FFE4C4");
    public static final Color Black = rgb("000000");
    public static final Color BlanchedAlmond = rgb("FFEBCD");
    public static final Color Blue = rgb("0000FF");
    public static final Color BlueViolet = rgb("8A2BE2");
    public static final Color Brown = rgb("A52A2A");
    public static final Color BurlyWood = rgb("DEB887");
    public static final Color CadetBlue = rgb("5F9EA0");
    public static final Color Chartreuse = rgb("7FFF00");
    public static final Color Chocolate = rgb("D2691E");
    public static final Color Coral = rgb("FF7F50");
    public static final Color CornflowerBlue = rgb("6495ED");
    public static final Color Cornsilk = rgb("FFF8DC");
    public static final Color Crimson = rgb("DC143C");
    public static final Color Cyan = rgb("00FFFF");
    public static final Color DarkBlue = rgb("00008B");
    public static final Color DarkCyan = rgb("008B8B");
    public static final Color DarkGoldenRod = rgb("B8860B");
    public static final Color DarkGray = rgb("A9A9A9");
    public static final Color DarkGreen = rgb("006400");
    public static final Color DarkKhaki = rgb("BDB76B");
    public static final Color DarkMagenta = rgb("8B008B");
    public static final Color DarkOliveGreen = rgb("556B2F");
    public static final Color Darkorange = rgb("FF8C00");
    public static final Color DarkOrchid = rgb("9932CC");
    public static final Color DarkRed = rgb("8B0000");
    public static final Color DarkSalmon = rgb("E9967A");
    public static final Color DarkSeaGreen = rgb("8FBC8F");
    public static final Color DarkSlateBlue = rgb("483D8B");
    public static final Color DarkSlateGray = rgb("2F4F4F");
    public static final Color DarkTurquoise = rgb("00CED1");
    public static final Color DarkViolet = rgb("9400D3");
    public static final Color DeepPink = rgb("FF1493");
    public static final Color DeepSkyBlue = rgb("00BFFF");
    public static final Color DimGray = rgb("696969");
    public static final Color DodgerBlue = rgb("1E90FF");
    public static final Color Feldspar = rgb("D19275");
    public static final Color FireBrick = rgb("B22222");
    public static final Color FloralWhite = rgb("FFFAF0");
    public static final Color ForestGreen = rgb("228B22");
    public static final Color Fuchsia = rgb("FF00FF");
    public static final Color Gainsboro = rgb("DCDCDC");
    public static final Color GhostWhite = rgb("F8F8FF");
    public static final Color Gold = rgb("FFD700");
    public static final Color GoldenRod = rgb("DAA520");
    public static final Color Gray = rgb("808080");
    public static final Color Green = rgb("008000");
    public static final Color GreenYellow = rgb("ADFF2F");
    public static final Color HoneyDew = rgb("F0FFF0");
    public static final Color HotPink = rgb("FF69B4");
    public static final Color IndianRed = rgb("CD5C5C");
    public static final Color Indigo = rgb("4B0082");
    public static final Color Ivory = rgb("FFFFF0");
    public static final Color Khaki = rgb("F0E68C");
    public static final Color Lavender = rgb("E6E6FA");
    public static final Color LavenderBlush = rgb("FFF0F5");
    public static final Color LawnGreen = rgb("7CFC00");
    public static final Color LemonChiffon = rgb("FFFACD");
    public static final Color LightBlue = rgb("ADD8E6");
    public static final Color LightCoral = rgb("F08080");
    public static final Color LightCyan = rgb("E0FFFF");
    public static final Color LightGoldenRodYellow = rgb("FAFAD2");
    public static final Color LightGrey = rgb("D3D3D3");
    public static final Color LightGreen = rgb("90EE90");
    public static final Color LightPink = rgb("FFB6C1");
    public static final Color LightSalmon = rgb("FFA07A");
    public static final Color LightSeaGreen = rgb("20B2AA");
    public static final Color LightSkyBlue = rgb("87CEFA");
    public static final Color LightSlateBlue = rgb("8470FF");
    public static final Color LightSlateGray = rgb("778899");
    public static final Color LightSteelBlue = rgb("B0C4DE");
    public static final Color LightYellow = rgb("FFFFE0");
    public static final Color Lime = rgb("00FF00");
    public static final Color LimeGreen = rgb("32CD32");
    public static final Color Linen = rgb("FAF0E6");
    public static final Color Magenta = rgb("FF00FF");
    public static final Color Maroon = rgb("800000");
    public static final Color MediumAquaMarine = rgb("66CDAA");
    public static final Color MediumBlue = rgb("0000CD");
    public static final Color MediumOrchid = rgb("BA55D3");
    public static final Color MediumPurple = rgb("9370D8");
    public static final Color MediumSeaGree = rgb("3CB371");
    public static final Color MediumSlateBlue = rgb("7B68EE");
    public static final Color MediumSpringGreen = rgb("00FA9A");
    public static final Color MediumTurquoise = rgb("48D1CC");
    public static final Color MediumVioletRed = rgb("C71585");
    public static final Color MidnightBlue = rgb("191970");
    public static final Color MintCream = rgb("F5FFFA");
    public static final Color MistyRose = rgb("FFE4E1");
    public static final Color Moccasin = rgb("FFE4B5");
    public static final Color NavajoWhite = rgb("FFDEAD");
    public static final Color Navy = rgb("000080");
    public static final Color OldLace = rgb("FDF5E6");
    public static final Color Olive = rgb("808000");
    public static final Color OliveDrab = rgb("6B8E23");
    public static final Color Orange = rgb("FFA500");
    public static final Color OrangeRed = rgb("FF4500");
    public static final Color Orchid = rgb("DA70D6");
    public static final Color PaleGoldenRod = rgb("EEE8AA");
    public static final Color PaleGreen = rgb("98FB98");
    public static final Color PaleTurquoise = rgb("AFEEEE");
    public static final Color PaleVioletRed = rgb("D87093");
    public static final Color PapayaWhip = rgb("FFEFD5");
    public static final Color PeachPuff = rgb("FFDAB9");
    public static final Color Peru = rgb("CD853F");
    public static final Color Pink = rgb("FFC0CB");
    public static final Color Plum = rgb("DDA0DD");
    public static final Color PowderBlue = rgb("B0E0E6");
    public static final Color Purple = rgb("800080");
    public static final Color Red = rgb("FF0000");
    public static final Color RosyBrown = rgb("BC8F8F");
    public static final Color RoyalBlue = rgb("4169E1");
    public static final Color SaddleBrown = rgb("8B4513");
    public static final Color Salmon = rgb("FA8072");
    public static final Color SandyBrown = rgb("F4A460");
    public static final Color SeaGreen = rgb("2E8B57");
    public static final Color SeaShell = rgb("FFF5EE");
    public static final Color Sienna = rgb("A0522D");
    public static final Color Silver = rgb("C0C0C0");
    public static final Color SkyBlue = rgb("87CEEB");
    public static final Color SlateBlue = rgb("6A5ACD");
    public static final Color SlateGray = rgb("708090");
    public static final Color Snow = rgb("FFFAFA");
    public static final Color SpringGreen = rgb("00FF7F");
    public static final Color SteelBlue = rgb("4682B4");
    public static final Color Tan = rgb("D2B48C");
    public static final Color Teal = rgb("008080");
    public static final Color Thistle = rgb("D8BFD8");
    public static final Color Tomato = rgb("FF6347");
    public static final Color Turquoise = rgb("40E0D0");
    public static final Color Violet = rgb("EE82EE");
    public static final Color VioletRed = rgb("D02090");
    public static final Color Wheat = rgb("F5DEB3");
    public static final Color White = rgb("FFFFFF");
    public static final Color WhiteSmoke = rgb("F5F5F5");
    public static final Color Yellow = rgb("FFFF00");
    public static final Color YellowGreen = rgb("9ACD32");
    public Colors() {  }
    private static Color rgb(String hexValue){
    return(new Color(
    Integer.parseInt(hexValue.substring(0, 2), 16),
    Integer.parseInt(hexValue.substring(2, 4), 16),
    Integer.parseInt(hexValue.substring(4), 16)));

  • Who can help me write this Java code show the prime number ???? PLEASEEEEEE

    Write java code print prime number like this
    Sample Screen Print:
    Initial matrix with N = 37
    2 3 4 5 6 7 8 9 10
    11 12 13 14 15 16 17 18 19 20
    21 22 23 24 25 26 27 28 29 30
    31 32 33 34 35 36 37
    Intermediate results (after 1st iteration)
    2 3 5 7 9
    11 13 15 17 19
    21 23 25 27 29
    31 33 35 37
    Intermediate results (after 2nd iteration)
    2 3 5 7
    11 13 17 19
    23 25 29
    31 35 37
    Intermediate results (after 7th iteration)
    2 3 5 7
    11 13 17 19
    23 29
    31 37
    Final results
    2 3 5 7 11 13 17 19 23 29
    31 37
    How to write this code ?
    Please Help me!
    Thank you so muchhh ?????

    h2. {color:#ff0000}Multiplepost{color}
    Replies here: http://forum.java.sun.com/thread.jspa?threadID=5241012&tstart=0
    There is a useful answer the original thread. Answer it, or ignore it as you like, but don't create multiple threads.

  • Java code to convert XML file to ISO XML format

    Hi Experts,
    I need to convert an XML file to ISO Xml format using Java code.I dont have any idea about the ISO XML format.I searched but what i am getting is ISO is an encoding in XML.
    It will be very helpful if any one can give me a sample ISO XML file, and any way around to carry out the required conversion.
    Thanks .
    Anika

    Hi,
    For ISO encoding you need the XML file to be converted with below providing the encoding paramter as ISO. for e.g.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    instead of
    <?xml version="1.0" encoding="UTF-8"?>
    this can be possible with using XML encoders.
    Refer XML encoding--> http://www.w3schools.com/XML/xml_encoding.asp
    Refer Java Code with uasage of XMLEncoder
    http://java.sun.com/j2se/1.4.2/docs/api/java/beans/XMLEncoder.html
    Thanks
    Swarup

  • Text formatted like Java code

    I was going to put some examples of java code on a website that I'm currently building, what is the easiest way to format the HTML to look like some of the code examples used in these forums? Could I do it with a stylesheet or XML or would I have to do something really complicated?

    Just use normal html: heres a template:-
    <html>
    <title>* Your title *</title><head><h4>AProgram.java</h4><hr></head
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <body bgcolor='white'>
    <table border=0 cellPadding=2 cellSpacing=0 width="100%">
    <TR><td width="8%"></td>
    <td width=80%></td><td></td></tr>
    <tr></td><td><td><font face='Courier' size='3' color='black'>
    public class AProgram {
    </body>
    </head>
    Don't use the <pre> tag as cuases the text to be unusually spaced or to come out tiny for those using resolutions above 800 x 600 and you'll need to hand code certain things eg;-
         space = & nbsp ; // close the spaces
         left tag '<' = & lt ; // close the spaces
         right tag '>' = & gt ; // close the spaces

  • Format Java Code with jdeveloper

    Hi Everybody,
    Can anybody tell me How I can Indent Java Code Automatically using JDeveloper 9i.
    It is a facility which is provided in almost all the editor and I believe it should be in jdeveloper also but the problem is I dont know how to go for it.
    I will be very kind to anybody who will solve this problem as this will reduce my lot of unwanted work.
    Regards,
    Amit Jain

    If you're looking for a code beautifier (a tool that can apply a coding style to your source code automatically), try the Jalopy extension. It's an open source code beautifier that is tightly integrated with JDeveloper:
    http://jalopy.sourceforge.net/plugin-jdev.html
    Thanks,
    Brian
    JDev Team

  • JAVA CODE  NOT CREATING IDOC

    Hi all
    I m facing problem to upload data through idoc.the scenario is like we receive electric meter reading in flat file format. And to upload that data JAVA code is written which will create an IDOC FILE this authorization is only give to 2-3 person in organization and to basis guy also as user changed it’s password in SAP and in JAVA the java code is not going to create the IDOC file and data is not going to upload. after changing user password in sap system ,user not able to upload the data.
    ISU_MR_UPLOAD01 is the idoc file generated. So is there any authorization issue, password issue how to see and view IDOC IN SAP, can any one help me out into this.
    The error with java throws is as;
    1ST ERROR IN TRACE FILE
    ERROR file opened at 20061109 133610 India Standard, SAP-REL 640,0,59 RFC-VER 3  MT-SL
    T:2736 ======> User TR has no RFC authorization for function group SYST .
    T:2736 <* RfcReceive [1] : returns 3:RFC_SYS_EXCEPTION
    2ND ERROR ON COMMAND PROMT
    C:\j2sdk1.4.2_07>cd bin
    C:\j2sdk1.4.2_07\bin>java sandsupload
    Creating IDoc...Exception in thread "main" com.sap.mw.idoc.IDoc$Exception: (2) I
    DOC_ERROR_METADATA_UNAVAILABLE: The meta data for the IDoc type "ISU_MR_UPLOAD01
    " is unavailable.
            at com.sap.mw.idoc.jco.JCoIDoc$JCoDocument.<init>(JCoIDoc.java:233)
            at com.sap.mw.idoc.jco.JCoIDoc$JCoDocument.<init>(JCoIDoc.java:187)
            at com.sap.mw.idoc.jco.JCoIDoc.createDocument(JCoIDoc.java:10521)
            at sandsupload.main(sandsupload.java:35)
    the part of java code
    try {
                //create a JCo client pool
                JCO.addClientPool( "MyPool",    //pool name
                                   3,           //maximum pool connections
                                   "333",       //SAP client
                                   " TR",    //user ID
                                   " XYZ",  //password
                                   "EN",        //language
                                   " 1.1.1.1   ", //app server host name
                                   "00" );   //system number
                //create an IDoc repository
                IDoc.Repository idocRep = JCoIDoc.createRepository("MyIDocRepository", "MyPool");
                //create a new and empty MATMAS02 document
                System.out.print("Creating IDoc...");
         Line where it shows error
                IDoc.Document doc = JCoIDoc.createDocument(idocRep, "ISU_MR_UPLOAD01");
                //get the root segment from the document
                //The root segment does not contain any fields or data. It is only
                //used as the standard parent segment and won't be transmitted when
                //the document is sent to an SAP system.
                IDoc.Segment segment = doc.getRootSegment();
                //create and add a new and empty child segment of type E1MARAM
                //and fill the segment data

    Hi Gaurav,
    Same exception on the same line has been reported and marked as solved here :
    IDOC_ERROR_METADATA_UNAVAILABLE:
    Btw, I think this forum is not visited often by JCO and ABAP connectivity experts, so maybe you could get a faster response to your problems while posting in "Java Programming" or maybe in some forum under the category ABAP Development.
    HTH
    Peter

  • Number Formating

    Hi,
    I'm using the following code for formating a number,
         public static String formater(double value ) {
              Locale loc = new Locale("en", "US");
              NumberFormat nf = NumberFormat.getNumberInstance(loc);
              DecimalFormat df = (DecimalFormat)nf;
              df.applyPattern("###,###,###,###,##0.00");
              String output = df.format(value);
              return output;
    This is working fine for all the values, but for some scenarios, its giving errors.
    for e.g.,
         if the value is 532.875, then the result is 532.88
         but if the value is 165158.005, then the result is 165,158.00. Where as this should be 165,158.01.
    you can test this at
         http://journals.ecs.soton.ac.uk/java/tutorial/intl/datamgmt/numbers.html
    I hope this is a bug in java. Can someone please help me out in solving this error. i need it very urgently.
    Thanks in advance.
    Shiva

    Not a bug. When you think you've found a bug, the first thing to do is read the documentation and make sure you understand how it's supposed to work. According to the DecimalFormat javadoc, "half-even rounding" is used. This means that if two nearest neighbor values are equidistant, it rounds to the even value.

  • Date and Number formatting

    Hi All
    I am getting data from RFC and able to bind it into table. Now I want to format date and numbers into user logged in format. i.e. If user enters country as Germany while registration,date format should be European in table displayed otherwise it should be US format.
    Can any one suggest me how to do it?

    Thanks for your your Help Abhilash. I slightly changed code and now its working. I think this is almost same thing that you discussed.You can see code below.
    Can you help in working with Number  format also? I am getting number format exception. String returned when RFC executed is in 10,000,00. I need to change according to user locale format. I tried doing it in java also. When I remove commas in above string its working fine.
    public java.lang.String DisplayingDateFormat( java.lang.String date )
        //@@begin DisplayingDateFormat()
                        // Current date Format in BW
                             SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy");
                             String ChangedDateFormat=null;
    try{
    //     sdf.setLenient(false);
    //Parsing String to Date
         Date sqlDate =sdf.parse(date);
    //     wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(" Source date"+ ele.getSched_Date());
    //     wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(" Date converted "+sqlDate);
    //       Getting User Locale
    //Getting Locale Information form Current Session
         Locale userLocale= WDResourceHandler.getCurrentSessionLocale();
         //wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(" User Current Locale "+userLocale );
    //Setting date format ie Short,default etc
         DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, userLocale);
         //wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(" Formatting to user locale ");
         //Converting Date to String
         String newDateString = dateFormat.format(sqlDate);
         //wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(" Changed Date Format "+newDateString);
         //binding to Table UI element
         ChangedDateFormat=newDateString;
    catch(Exception e)
         wdThis.wdGetAPI().getComponent().getMessageManager()
                             .reportException(
                             e.toString(),
                             false);

  • How to pass the parameter values to the stored procedure from java code?

    I have a stored procedure written in sqlplus as below:
    create procedure spInsertCategory (propertyid number, category varchar2, create_user varchar2, create_date date) AS BEGIN Insert into property (propertyid, category,create_user,create_date) values (propertyid , category, create_user, create_date); END spInsertCategory;
    I am trying to insert a new row into the database using the stored procedure.
    I have called the above procedure in my java code as below:
    CallableStatement sp = null;
    sp = conn.prepareCall("{call spInsertCategory(?, ?, ?, ?)}");
    How should I pass the values [propertyid, category, create_user, create_date) from java to the stored procedure?[i.e., parameters]
    Kindly guide me as I am new to java..

    Java-Queries wrote:
    I have a stored procedure written in sqlplus as below:FYI. sqlplus is a tool from Oracle that provides a user interface to the database. Although it has its own syntax what you posted is actually PL/SQL.

Maybe you are looking for