Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    21
    Rep Power
    0

    Default Problem with text field patern

    hi ,
    I have a number which data type is String now I want to apply field Pattern to that field

    $F{balance}.toString().contains("-")?new DecimalFormat("#,###,###,##0.00").format(new BigDecimal($F{balance}.doubleValue()).abs().toStri ng())+"Dr":$F{balance}.toString()+"Cr"
    but when I run my report I face "java.lang.IllegalArgumentException:*Cannot*format *given*Object*as*a*Number*"

    this error...

    Plz help me
    Thanking You
    Prashant

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    Well, you have managed to put five or six operations into one line of code. Create a few fields and break the statement up into several statements. Focus on the statement that doesn't work. I suspect that the BigDecimal constructor is throwing the exception, but I can't be sure.

    In general, your peers at work will like you a lot better if you don't ever create long statements like that. At my first job, we used to avoid working on the code written one senior developer, MD. You don't want people to remember you twenty years later because they hated working on your code...

Similar Threads

  1. How To add the Text field to the TextArea or TextPane
    By Chintan Patel in forum AWT / Swing
    Replies: 3
    Last Post: 04-08-2009, 03:46 AM
  2. launching Jframe from text field
    By crunchymonkey in forum AWT / Swing
    Replies: 4
    Last Post: 10-15-2008, 03:50 AM
  3. need to add text field on existing dialog
    By SHAshank1 in forum SWT / JFace
    Replies: 0
    Last Post: 07-23-2008, 04:15 PM
  4. get numeric value from a text field
    By Lehane_9 in forum New To Java
    Replies: 2
    Last Post: 06-14-2008, 04:19 AM
  5. Regarding Text Field
    By adeeb in forum AWT / Swing
    Replies: 1
    Last Post: 06-06-2008, 12:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •