Results 1 to 5 of 5
  1. #1
    narayan1ap is offline Member
    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Default DateFormatter.formatRawCellContents throwing IllegalArgumentException for 0.0 value.

    Hi,

    I am trying to read a xlsm file with POI

    switch (cell.getCachedFormulaResultType()) {

    case Cell.CELL_TYPE_NUMERIC:
    double value = cell.getNumericCellValue();
    int formatIndex = cell.getCellStyle().getDataFormat();
    String formatStr = cell.getCellStyle().getDataFormatString();
    formatted = dateFormatter.formatRawCellContents(0.0, formatIndex, formatStr);
    break;

    }

    Whenever there is value 0.0 formatRawCellContents api is throwing IllegalArgument Execption.

    Any Idea ?

    Thanks
    Narayan

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,029
    Rep Power
    6

    Default Re: DateFormatter.formatRawCellContents throwing IllegalArgumentException for 0.0 val

    Of course, 0.0 is not a date. Its a double.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    narayan1ap is offline Member
    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Default Re: DateFormatter.formatRawCellContents throwing IllegalArgumentException for 0.0 val

    But it works for double values other than 0.0
    What I understood was excel stores dates in terms of numbers right ?

    And also the observation is whenever I have these arguments it is throwing the IllegalArgumentexception.

    Value= 0.0 FormatIndex= 174 FormatString= mm/dd/yyyy;;;
    Last edited by narayan1ap; 08-23-2013 at 03:41 PM.

  4. #4
    narayan1ap is offline Member
    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Default Re: DateFormatter.formatRawCellContents throwing IllegalArgumentException for 0.0 val

    there was a typo.
    It is not dateFormatter. DataFormatter.

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,029
    Rep Power
    6

    Default Re: DateFormatter.formatRawCellContents throwing IllegalArgumentException for 0.0 val

    He he, what a difference one little character can make! :)

    You fail to mention if your problem is now solved or if there simply was a typo in your original post.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 13
    Last Post: 08-13-2012, 07:53 PM
  2. Replies: 3
    Last Post: 03-24-2011, 06:18 AM
  3. JPA java.lang.IllegalArgumentException
    By johnwcv in forum Advanced Java
    Replies: 0
    Last Post: 03-17-2011, 10:17 PM
  4. Replies: 1
    Last Post: 11-20-2010, 11:28 PM
  5. proper use of IllegalArgumentException
    By vendetta in forum New To Java
    Replies: 1
    Last Post: 01-16-2010, 07:43 PM

Posting Permissions

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