We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Invalid date format output

Hi. I have found, that Russian months output in invalid form (not like in Excel). For example following test fails, because string value in cell not matched with Excel’s value. I’ve performed this test in different environments, but every time i have incorrect result:

    @Test
public void month() throws Exception {
    Workbook wb = new Workbook("D://in.xlsx");
    Cell cell = wb.getWorksheets().get(0).getCells().get("A1");

    assertEquals("Июль 2018", cell.getDisplayStringValue());
}

org.junit.ComparisonFailure: 
Expected :Июль 2018
Actual   :июля 2018

in.zip (6.4 KB)
Безымянный.png (13.3 KB)

PS Can you please permit to attach xls, xlsx, xlsm files. It is very uncomfortable to archive that files

@makarovalv

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-42688 - Invalid date format output

Moreover, from security point of view XLS, XLSX or XLSM files are not allowed to be uploaded directly as there can be spams (written in different scripts) which can be renamed to XLS/XLSX files. So we recommend archiving the files and uploading them to forums.

@makarovalv,

Please see our reply for the same issue posted by another user:

Here, by our tests we can get the correct results for A1’s StringValue: Июль 2018. The formatted result should be determined by the installed JDK of your environment. You may check whether SimpleDateFormat with pattern “MMMM” and Russian locale can give the expected result without referencing to/using our component.

Hi.

Thank you for link. Can you please provide JDK version, that you used for test and (if it is possible) - a small piece of code, that returns “Июль 2018” from library.
I asked it, because it very strange, that this issue was raised recently.

I’m using jdk 1.8.181 (switching default locale not influence on result)

Best regards. Alexey

@makarovalv,

Could you check whether SimpleDateFormat with pattern “MMMM” and Russian locale gives your the expected results or not without involving Aspose.Cells APIs?

It is too complex to check every time a cell’s format and use SimpleDateFormat with different formats, that used for cell. Easier to find some environment difference and fix it.

@makarovalv,

We will further evaluate your issue and get back to you soon.

@makarovalv,

For “try SimpleDateFormat with pattern “MMMM” and Russian locale”, it is not to require you to try it for every cell, but you may just try the code like following:
e.g
Sample code:

System.out.println(new SimpleDateFormat("MMMM yyyy", new Locale("ru", "RU")).format(new Date(2018,6,11)));
and verify whether it can give the expected results with your Java environment or not.

By our further investigation, we found it is the JDK who changed its behavior for formatting, it is not an issue with Aspose.Cells APIs. For JDK1.6, the output is just same with the expected one. But for JDK1.8, it gives the “incorrect” result. Currently we cannot find any solution for JDK1.8 to let it to format same with 1.6 or cope with it.

We are sorry for any inconvenience caused!

Thank you for investigation. Do you have plans to update JDK up to 1.8? It is very important, because 1.6 is very old version

@makarovalv,

As we told you that we could not find any solution for JDK1.8 for your issue. Anyways, if there is any new information to be shared, we will let you know.

Hey, guys!

Thank you for working on this problem!

In Java 8 class SimpleDateFormat has 2 types “Month in year” pattern letters.
M - Month in year (context sensitive)
L - Month in year (standalone form)

So, if I use code: System.out.println(new SimpleDateFormat("MMMM yyyy", new Locale("ru", "RU")).format(new Date()));
It returns "августа 2018"

But, if I use: System.out.println(new SimpleDateFormat("LLLL yyyy", new Locale("ru", "RU")).format(new Date()));
It returns “Август 2018”, as we need.

Maybe this is a solution?

@makarovalv,

Thanks for the suggested solution. We will try to evaluate it further. Once we have an update on it, we will let you know here.

@makarovalv,

We are investigating the month pattern ‘M’ and ‘L’ for JDK1.8 or later, and will determine whether it is appropriate to replace all ‘M’ by ‘L’.

Once we figure it out, we will let you know.

@makarovalv,

This is to inform you that we have fixed your issue now. We will soon provide you the fix after performing QA and incorporating other enhancements and fixes.

@makarovalv,

Please try our latest version/fix: Aspose.Cells for Java v18.9.4 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells for Java_v18.9.4.zip (6.3 MB)

Hi, it seems that it works. Thank you very much!
Best regards. Alexey

@makarovalv,

Good to know that it is working for you. Feel free to write us back if you have further comments or questions, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSJAVA-42688) have been fixed in Aspose.Cells for Java 18.10. You can also get the latest Aspose.Cells for Java version from Maven repos. with simple configurations. Please see the document for your reference: https://docs.aspose.com/display/cellsjava/Installation

This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

Hi. I’ve repeated this issue with another case

@Test
public void month() throws Exception {
    Workbook wb = new Workbook("E://in.xlsx");
    Cell cell = wb.getWorksheets().get(0).getCells().get("A1");
    assertEquals("Июль 2018", cell.getDisplayStringValue());
    cell = wb.getWorksheets().get(0).getCells().get("A2");
    assertEquals("Июль 2018", cell.getDisplayStringValue());
}

For A2 i’ve used custom russian format “ММММ ГГГГГ”, that should display time in same kind, but Aspose.Cells returns wrong value.in.zip (6.4 KB)

Best regards. Alexey

@makarovalv,

Thanks for the sample code and template file.

I opened your template file into MS Excel but A2 cell is not Russian (custom) formatted (it is simple custom formatted), see the screenshot for your reference:
https://i.imgur.com/GtE1QQ3.png