Format decimal values by using comma

hi,
Can anyone tell me how to format decimal value in JTextField by using comma. Since this JTextField is used to display amount,so i would like to put comma after three digits. That means it should look like this : 100,000,000.00. This JTextField is the total of another 9 JTextField values, that means when i edit values in another JTextField, the total value will be upated as well. I have used KeyEvent to do so , now i just have no idea how to apply comma in the total. Thanks for any help.
Regards,
marcalena

Hmm....
First off, this is not ideal... I would seriously consider updating your JRE...
public class MyDecimalDocument extends javax.swing.text.PlainDocument
///init code
public void insertString(int offset, String newString, javax.swing.text.AttributeSet set) throws javax.swing.text.BadLocationException
//code to handle the inserts and restrict/apply various formatting....
}Or check out [url http://onesearch.sun.com/search/developers/index.jsp?col=devforums&qp_name=Swing&qp=forum%3A57&qt=formatting+JTextField]this search for more...
:)

Similar Messages

  • Data type for decimal value

    I am making my own database table.which data type shuld I use to display decimal values.I used FLTP but its display is not very clear.
    My values are like1234.56
    Thanks

    assign decimal place while creating domine.
    as per ur req.....
    if it is usefulll.Plz Reward
    Regards
    Anbu

  • Why is it such a pain to use java in a country that uses commas as decimal?

    Why is it such a pain to use java in a country that uses commas as decimal separator?
    A few weeks back I've asked here about the keypad decimal key. For some reason, java doesn't map the decimal key to a comma on the Portuguese (Portugal) keyboard layout. I've got no answer and I ended up using a custom plainDocument on the JTextFields to replace all points with commas.
    Now, I've just spent the whole morning trying to store and use decimal numbers properly. For some reason, a Double/Float .valueOf method (or the corresponding parse method) simply ignores the locale in use and uses US defaults when parsing the string. I can't parse anything with commas in those methods and I should, as it is the decimal separator for the system and default locale being used by java.
    First of all, I shouldn't be expected to perform replacements on every single operation that comes with a comma and I obviously can't be expected to program my own locale checking to decide what decimal separator to use in each final system. Second, is there any way to work with numbers seamlessly, without having to know the locale of the end user?
    I'm sorry if this is all my fault for doing something completly wrong, I'm new to java and I did search around to no avail. I'm really frustrated with what seems to be a complete lack of support in java for locales other than the US one.

    Good old Cobol has the "DECIMAL-POINT IS COMMA" clause... And isn't it great? :)
    Second, is there any way to work with numbers seamlessly, without having to know the locale of the end user?Consider "123.456". In some locales, this number is one hundred twenty-three thousand, four hundred fifty-six. In other locales it is one hundred twenty-three and four hundred fifty-size thousandths. How will you be able to determine which, without a locale?That's not what I've meant. Java should know the locale and behave accordingly. I don't have to know the locale of the end user since it might vary greatly. My point is that if strings are flying around with commas and if comma is the decimal separator on the end user's machine, any method aimed at parsing a numeric value out of a string should regard commas as such. I'm constantly replacing dots with commas and vice versa which could cause trouble if a different locale is used.
    And I mean that as a rant. Given my inexperience with Java, there might be good reasons for such a behaviour as baftos argued. What I'm really interested is in finding the proper way to deal with this issue.
    Have you tried the NumberFormat.parse? I will now.
    Edited by: Smigh on Apr 9, 2008 9:21 AM

  • Converting char to decimal value format as defined in SU3(User profile)

    Hi Techies,
    Is there any FM to convert CHAR value into Decimal fomat as defined in SU3.
    If we use, WRITE statement for printing the value in decimal format , it shows the value in decimal format correctly
    in SU3 transaction , there are three different decimal format notations which can be user specific
    I would appreciate your valuable inputs ....
    Thanks
    Santhosh

    This is my code in a generic method to transform a table into a csvrow
    when 'P'.
            tmpstr = <p_field>.
            len = strlen( tmpstr ) - 1.
            tmpstr = tmpstr+0(len).
            if <p_field> < 0.
              sign = '-'.
            else.
              sign = ' '.
            endif.
            case decimalformat.
              when 'X' or 'E'.
                split tmpstr at '.' into int frac.
                ptmp = int.
                write ptmp to cp.
                shift cp left deleting leading space.
                replace all occurrences of '.' in cp with ','.
                concatenate
                  s
                  sign
                  cp
                  frac
                  delimiter
                into s in character mode.
              when 'Y' or 'D'.
                split tmpstr at '.' into int frac.
                ptmp = int.
                write ptmp to cp.
                shift cp left deleting leading space.
                replace all occurrences of ',' in cp with '.'.
                concatenate
                  s
                  sign
                  cp
                  frac
                  delimiter
                into s in character mode.
              when ' '.
                concatenate s sign tmpstr delimiter into s in character mode.
              when others.
                concatenate s '????????' delimiter into s in character mode.
            endcase.
    where pfield is a fieldsymbol type P. (honestly ist from type any, but determined by RTTI). I needed this cause i want to format the value from "outside" without taking the user settings in consideration as write...to.. is doing.
    What i'm doing is to use the write... to... clause modifying the result (change decimal point, thousand separator and sign) according to the demanded decimal notation.
    Edited by: Rainer Hübenthal on Oct 7, 2009 4:47 PM

  • Rounding to 2 decimal places WITHOUT using any formatting class

    Hello
    I'm trying to round a number (double) to 2 decimal places without using any of the formatting class like (DecimalFormat or Math.Round and BigDecimal). Is it possible to do it by just using typecast?

    OP:
    BigDecimal is not a formatting class. Math.round isn't a class at all.
    Typecasting doesn't really do that sort of thing at all (unless you count dropping fractional components when casting to an integer type).
    double holds values in binary format, so it's basically impossible to round to decimal values meaningfully.
    Chuck:
    I thought that BigDecimal supported arbitrary decimal precision, so one doesn't have to do that sort of thing....?

  • I would like to read a text file in which the decimal numbers are using dots instead of commas. Is there a way of converting this in labVIEW, or how can I get the program to enterpret the figures in the correct way?

    The program doest enterpret my figures from the text file in the correct way since the numbers contain dots instead of commas. Is there a way to fix this in labVIEW, or do I have to change the files before reading them in the program? Thanks beforehend!

    You must go in the labview option menu, you can select 'use the local
    separator' in the front side submenu (LV6i).
    If you use the "From Exponential/Fract/Eng" vi, you are able to select this
    opton (with a boolean) without changing the labview parameters.
    (sorry for my english)
    Lange Jerome
    FRANCE
    "Nina" a ecrit dans le message news:
    [email protected]..
    > I would like to read a text file in which the decimal numbers are
    > using dots instead of commas. Is there a way of converting this in
    > labVIEW, or how can I get the program to enterpret the figures in the
    > correct way?
    >
    > The program doest enterpret my figures from the text file in the
    > correct way since the numbers contain dots instea
    d of commas. Is there
    > a way to fix this in labVIEW, or do I have to change the files before
    > reading them in the program? Thanks beforehend!

  • How to load decimal values into a file using bcp in SQL Server 2000?

    Hi everyone,
    I'm trying to load data from a database table to a text file using bcp on SQL Server 2000. When I'm loading the decimal values, the values before the decimal are not being loaded into the file. How could I load the values before decimals?
    Here are the DDLs and DMLs of what I'm trying to run:
    CREATE TABLE [dbo].[Product_Sales](
    [Year_of_Sale] [smallint] NOT NULL,
    [Product_Type] [varchar](25) NOT NULL,
    [Product_Group] [varchar](25) NOT NULL,
    [Category_Type] [varchar](25) NOT NULL,
    [Category_Group] [varchar](10) NOT NULL,
    [Product_Count] [bigint] NOT NULL,
    [Product_Amount] [decimal](19, 2) NOT NULL,
    [Category_Count] [bigint] NOT NULL,
    [Category_Amount] [decimal](19, 2) NOT NULL,
    CONSTRAINT [PK_Product_Sales] PRIMARY KEY CLUSTERED
    [Year_of_Sale] ASC,
    [Product_Type] ASC,
    [Product_Group] ASC,
    [Category_Type] ASC,
    [Category_Group] ASC
    ) ON [PRIMARY]
    ) ON [PRIMARY]
    INSERT INTO [Yearly_Sales].[dbo].[Product_Sales]
    VALUES(2010, 'Online', 'Web', 'Cameras', 'Electronics', 547, 0.00, 0, 0.00)
    EXEC [master].[dbo].[xp_cmdshell] 'bcp "SELECT * FROM [Yearly_Sales].[dbo].[Product_Sales]" queryout D:\Yearly_Sales\Product_Sales.dat -c -T -S'
    And the output I see in the file is:
    2010 Online Web Cameras Electronics 547 .00 0 .00
    The values before decimals are being truncated.
    Thanks,
    Bangaaram
    Known is a DROP, Unknown is an OCEAN.

    You can modify the decimal column(s) in the table to varchar type before export. But it does not look good.
    alter table [dbo].[Product_Sales]
    Alter column [Product_Amount] varchar(20)
    alter table [dbo].[Product_Sales]
    Alter column [Category_Amount] varchar(20)
    Does that make any sense?
    Known is a DROP, Unknown is an OCEAN.
    Basically you modify the decimal column to a varchar type before you run the bcp command for export. You can modify your source table or you can modify them on the fly. It is just a workaround.
    Modifying the source wouldn't be a good idea. Never do that if you can't get your desired output.
    Known is a DROP, Unknown is an OCEAN.

  • Using comma (,) as a decimal separator

    I know this isn't the right place to ask, but I cant get excel to use comma as a decimal separator.
    All is set up right in system preferences and I still cant get it to work in excel.
    So Im asking if any one know how to make the comma to be used for the decimal numbers and dot for thousands.
    Or if any one can explain this to me, or better do it for me.
    http://www.macosxhints.com/article.php?story=20050926170928881
    Many thanks

    Hi, Sven.
    You might want to search or post on the Excel group you can find on the Microsoft Mac Support - Newsgroups page. These are Google Groups with active participation from MS product users, including a variety of expert users.
    I don't mean to send you somewhere else, but I've found numerous answers there for folks with questions related to MS products. Accordingly, it has often proved to be the first, best place to look for answers to questions such as you are asking.
    When you post your question there, be sure to state the version of Excel you are using.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X

  • Time format hours ("hh24") delim (.or,) (1/4) hour values as decimal value

    Dear all,
    What I need is a client (browser) site validation of values for a time recording system. The format should be as
    <hh24><Delimiter>(.(or),) 1/4 hours as decimal value (e.g. 15 minutes = 0.25). So as a result valid entrys should be. 00.00 as min., 24.00 as max.
    The "minutes"-part should only except full 1/4 hour values: 00, 25, 50, 75 or blank.
    More valid variation could be:
    .75 (45 minutes) should be considered as 00.75.
    1.25 , 9 ( = 9 hours)
    A colleague helped me and created the regexp pattern.
    (?<=\A)(([01]?[0-9]|2[0-4])[\.,]?)?([\.,](0{1,2}|25|50|75))?(?=(\z))
    It works perfect in "The Regex Coach", but sadly it does not work in a java script.
    My hope is, that someon already has a solution for this or a similar task.
    If so, please let me know and give me a hint.
    Thank you very much in advance.
    and best regards.
    Andre

    Hi Ben,
    thank you for your response.
    since I not only want to ask for help, I will let you konw our solution. It has been a little mind twisting
    However, Just in case someone is interestet in...
    function xaChk_TimeDecimalFormat(pItem)
       var check = $v(pItem);
       var regexpval = "^((([01]?[0-9])|(2[0-4]))?([,\.](00?))?|(([01]?[0-9])|(2[0-3]))?([,\.](00|25|50|5|75))?)$";
       if (check.search(regexpval,"g") < 0)
       {alert ('Ungültiges Zeiterfassungs-Format. \n gültig Werte sind: \n max. 24h und nur volle 1/4 Stunden als Decimalwert z.B. 0.25 für 15 Min.') };
    function xaChk_TimeClockFormat(pItem)
       var check = $v(pItem);
       var regexpval = "^((([01]?[0-9])|(2[0-4]))?([,\.](00))?|(([01]?[0-9])|(2[0-3]))?([,\.](00|15|30|45))?)$";
       if (check.search(regexpval,"g") < 0)
       {alert ('Ungültiges Zeiterfassungs-Format. \n gültig Werte sind: \n max. 24h und nur volle 1/4 Stunden als Minuten z.B. 0.15.') };
    ;Thanks again to all how wasted any thought on this. :-)
    Best Regards
    Andre

  • Adobe Reader/Acrobat hangs if single apostrophe is used incorrectly in format picture value statemen

    I am using the following Adobe Software and versions:
    Also, see the attached test file.
    If you try to open this file in Adobe Acrobat/Reader, it will hang.
    But, if you change the script on the text field on the form ready event, to be as follows:
    var theDftValue =
    'This sub-section will provide rational for country and sector'+
    "Support and relevance of the Bank''s intervention-in-line with Country "+
    "and sector analysis and major conclusions drawn in the above sections"
    this.format.picture.value = "null{'" + theDftValue  + "'}";
    Then it will work as expected.
    It took me several hours to find the source of the problem, so I am reporting hopefully it will be taken care of such in a future update.
    Click here to open the test file:
    https://docs.google.com/open?id=0B97clwYte2SHZElkSm1wcjNldGc
    (Note: from Google Drive, you have to take option File/Download to open the file locally.)
    Tarek.

    Since it doesn't seem like you are looking for support, locking this thread.

  • Converting Time format to Decimal Value

    Dear All,
    How to convert time to decimal value for substraction of time and decimal value
    for eg l_time type tims
           l_dec type p.
    l_diff = l_time - l_dec
    Kindly let me know.
    Thanks in Advacne,
    Ranjan

    Hi,
    Try like this...
    PARAMETERS : tim TYPE tims,
                 y TYPE p.
    DATA : t TYPE string,
           t1 TYPE string,
           t2 TYPE string,
           t3 TYPE string.
    START-OF-SELECTION.
      t = tim(2).
      t  = t * 3600. " hours to second
      t1 = tim+2(2).
      t1 = t1 * 60.  " minutes to second
      t2 = tim+4(2).
      t3 = t + t1 + t2. " total time in second
      t3 = t3 - y.
    Regards
    Debarshi

  • Decimal value in CSV file

    Hello everyone,
    it is my first post here.
    I'm trying to import a CSV file into Numbers, but the result is not quite what I was looking for. First of all, to get Numbers to open the file I had to drag and drop it into Numbers, I didn't find any other way to do it. I was looking for an "import" button that would let me give some kind of instructions on how to open the file, but did not find this button.
    In the CSV file, every numbers is separated by a comma, wich is normal, but the decimal portion of a value is also indicated by a comma and when imported it ends up in it's own column. So 4,5 might be 2 columns, the first one with the value 4 and the second one with the value 5, but 4,5 could also be the value 4,5. How do we tell Numbers how it should interpret the different values in a CSV file. Is it possible to say that column 4 is in fact the decimal part of value in column 3?
    Hopefully this is clear enough for you to understand.
    Thank you for your help.

    Hello
    The support of CSV files was described here many times.
    If the decimal separator in use on the system is the period, Numbers requires the original CSV format : Comma Separated Values.
    If the decimal separator in use on the system is the comma, Numbers requires the alternate CSV format : Semi-colon Separated Values.
    Given what you wrote, you are trying to import datas from a file using the original CSV format and the decimal comma.
    I know that some experts wrote Python filters to treat such case but I have no reference available at this time.
    If you send a sample file to my mailbox, I will try to write an AppleScript deciphering it.
    But as I often wrote, CSV is really the worst format ever invented. Why aren't you asking the document's author to use Tab Separated Values format ?
    Click my blue name to get my address.
    Yvan KOENIG (VALLAURIS, France) vendredi 22 avril 2011 11:04:21

  • Custom thousand separator for decimal values.

    Hello esperts,
    I have a a WD app with a decimal context attribute, I have already a Simple Type that formats the decimal so the thousand separator is a coma (,) and the decimal separator is the dot (.)
    I want to know if it is possible to change the thousand separator to dot and the decimal separator to comma without changing the user's language. Or even use whatever character I want to be the thousand separator e.g. @ | ¬ whithout changing the data type (decimal).
    Thanx in advance.
    JV

    Hi Siarhei,
    I dont want to use calculated fields, nor strings because I need the values of the decimal attribute. I will be desplaying these decimal values through a table and sorting functionality is a must. So as you should know, if I have 1, 2, 3, 20 and 100 and convert them to string, on sort it will be incorrect because of string sorting ( 1, 100, 2, 20 and 3).
    Basically my requirement is to be able to change the decimal presentation without changing the user's locale or language. I don't know if that's possible.
    Say, I select an option on my application that says "comma separated thousands", the decimal values will be presented this way ###,###,###,###.00 or when the user selects the option "dot separated thousands", the decimal values will be presented like this ###.###.###.###,00. I already tried to format the last reprersentation but I get java.lang.IllegalArgumentException: Malformed pattern. I have already checked the DecimalFormat API, so I know the pattern is incorrect, still I'm looking if by chance I'm forgeting something else to do in order the application to work as I spect.
    Thanks!
    JV

  • Rounding off to a variable value to 4 decimal values in sap script ouput

    Hi All,
    I have a value getting displayed in sap script output as 235.6789 i want to Round off this variable value to 4 decimal values!
    What is the formatting option need to be used & how!
    Thanks in advance.
    Thanks,
    Deep.

    Hi,
    1.In layout just call that variable, where you need like:
    &variable(.4)&.
    Just see these:
    &symbol(Z)&  Omit Leading Zeros 
    &symbol(S)&  Omit Leading Sign 
    &symbol(<)&  Display Leading Sign to the Left 
    &symbol(>)&  Display Leading Sign to the Right 
    &symbol(C)&  Compress Spaces 
    &symbol(.N)&  Display upto N decimal places 
    &symbol(T)&  Omit thousands separator 
    &symbol(R)&  Right justified 
    &symbol(I)&  Suppress output of the initial value
    Regards,
    If helpful reward with points(Don't forget).

  • Loading decimal  value to an infoobject of type char

    I have an extract structure with field timestamp, which is of type dec and length 15. Now i want to load this value to an infoobject in ODS. But this infoobject is of type char and length 18. when infopackage loading is scheduled it is giving the following error. Record 1 :InfoObject /BIC/IFITMSTMP does not contain alpa-conforming value 20061206084944.
    Is it because i tried to move a dec valu into a char field with a different length? If so  how will i load a decimal value of length 15 to a char of length 18. Can anyone please help me with this?
    Thanks in advance.

    if u r using BI7.0
    go to the datasource of the cube
    in the general info tab of the datasource
    there is a check box with PSA not typed
    check it
    if u check it all the values from the external source will be converted into character format irrespective of their data type

Maybe you are looking for

  • X Series is here – New Counter Features!

    Hey All, The new X Series Multifunction DAQ devices have been announced – check them out here. I’m posting here because I think X Series has several new counter features that many on this forum have been looking for. The user manual will have all of

  • Why can I only open the ringtone editor once per song?

    I thought the free song of the week (Carol of the Bells) had a section that would make a good ringtone. I opened the ringtone editor to see how it worked and whether I could pick out the section I wanted. I then cancelled out of the ringtone editor s

  • Could not establish secure connection with server

    Hi , We are not able to access our web service URL from Ipad Application on some of the network. We are receiving "could not establish secure connection with the server" message. We are able to access the same URL from other networks. Can you please

  • After Effects Rendering keeps failing

    Hi, So recently I am having an issue with rendering / exporting a project in After Effects CC or even linking the project to Premiere Pro CC and rendering that way. Video will get to about 10% and fail the render process within After Effects, When li

  • Site "crashes" when attempting to return to inbox after full scan and numerous crash reports.

    Problem just began on 1/25/13. Can view any site on hotmail window or web browser. When finished with site and attempt to return to Firefox site by either X in viewed site or back arrow site crashes and comes up with a crash report site. I have been