Exception for odd custom date format

Hi,


A colleague of mine wanted a date format with AM/PM output and invoked the method Style.setCustom with “yyyy-MM-dd hh:mm am” (which should have been “yyyy-MM-dd hh:mm AM/PM”).
Altough wrong, it should still produce output such as
2013-12-18 11:30 a30,
2010-05-26 14:45 a45,
2010-05-04 10:54 a54,
2009-12-21 02:48 a48, in Excel (which I tested directly in Excel to verify).

But Aspose throws an Exception instead
java.lang.ArrayIndexOutOfBoundsException: 19
at com.aspose.cells.zuz.a(Unknown Source)
at com.aspose.cells.zuw.a(Unknown Source)
at com.aspose.cells.Style.b(Unknown Source)
at com.aspose.cells.Style.setCustom(Unknown Source)
(tested versions include 8.4.0 and 8.4.1).

So, even if the output will be weird, Aspose should be able to allow the same custom formats as Excel.

Best regards
Claes

Hi,


Thanks for providing details.

After an initial test, I observed the issue as you mentioned. I found the Exception “java.lang.ArrayIndexOutOfBoundsException” occurred for an odd custom Date format. I used the following sample code with Aspose.Cells APIs:
e.g
Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
Cell cell = worksheet.getCells().get(“A1”);

Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
cell.putValue(c.toString(), true);
Style style = cell.getStyle();
style.setCustom(“yyyy-MM-dd hh:mm am”); //Exception
cell.setStyle(style);

workbook.save(“out1.xlsx”);

I have logged a ticket with an id “CELLSJAVA-41280” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,

Thanks for using Aspose.Cells for Java.

Please download and try this fix: Aspose.Cells for Java v8.4.1.1 and let us know your feedback.

Hi,


This works great, thank you!

Best regards
Claes

Hi,


Thanks for your feedback.

Good to know that your issue is sorted out by the new fix. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-41280) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.