Date separator is different for each platform

If you run the following code, the results will be different on macOS and Linux. Why is that?

const book = new aspose.cells.Workbook()
const settings = book.getSettings()
settings.setRegion(aspose.cells.CountryCode.JAPAN)
settings.setLanguageCode(aspose.cells.CountryCode.JAPAN)

const cell = book.getWorksheets().get(0).getCells().get("A1")
cell.setValue(43831)

const style = new aspose.Style()
style.setNumber(14)
cell.setStyle(style)

const formatted_value = cell.getStringValue()
console.log(formatted_value)

console.log(book.getSettings().getLocale().toString())
console.log(book.getSettings().getRegion())
console.log(book.getSettings().getLanguageCode())

macOS

2020-01-01
ja_JP
81
81

Linux

2020/01/01
ja_JP
81
81

aspose-cells-19.1.jar is used through nodejs

@furuta,

The only difference is the formatted value/text retrieved. May be it is due to different OS’ (macOS and linux) culture or regional settings. Anyways, could you try using our latest Aspose.Cells for Node.js via Java v19.8 and let us know your feedback:

@Amjad_Sahi

I’m sorry that the confirmation was delayed.
I checked with latest version, but the result was the same.

@furuta,

For locale-depended formatting, we use Java’s builtin number formatter to get the locale specific settings, which may vary according to different platforms, jvms, environment settings, …etc.

Please try below code for your two environments to see whether they give different results or not:

System.out.println(DateFormat.getDateInstance(DateFormat.SHORT, new java.util.Locale(“ja”,“JP”)).format(new java.util.Date()));

When run in java, the results were the same. However, if execute the following code in node-java, the result will be different.

const java = require("java")
const DateFormat = java.import("java.text.DateFormat")
const Locale = java.import("java.util.Locale")
const Date = java.import("java.util.Date")

console.log(DateFormat.getDateInstanceSync(DateFormat.SHORT, new Locale("ja", "JP")).formatSync(new Date()))

macOS

 2020-02-15

Linux

 2020/02/15

@furuta,

What result you get on both environments (macOS and Linux), kindly paste here.

It looks like this:

macOS

2020/02/15

Linux

2020/02/15

@furuta,
We are working on this issue and will share our feedback soon.

@furuta,
As we have said, we use Java’s builtin number formatter to get locale-dependent settings. If you get ‘/’ or ‘-‘ as separator from the default DateFormat, then the formatted result of our component will be ‘/’ or ‘-‘ too. However, It is strange that you get different results for java program and nodejs for the same mac platform. Please check whether you are using the same jdk for both of them? You may check the jdk by code like:

Java:

System.out.println(DateFormat.getDateInstance(DateFormat.SHORT, new Locale("ja", "JP")).format(new Date()));

System.out.println(System.getProperty("java.home"));

NodeJs:

console.log(DateFormat.getDateInstanceSync(DateFormat.SHORT, new Locale("ja", "JP")).formatSync(new Date()))

const System = java.import("java.lang.System")

console.log(System.getPropertySync("java.home"));

@furuta,

We did some further tests on MacOS and Linux. These are the details about environments we tested:

macos 10.10.5

nodejs 12.16

oracle jdk 11.0.4

aspose.cells 19.8.0

node-java 0.12.0

ubuntu1804

nodejs 12.16

oracle jdk 11.0.6

aspose.cells 19.8.0

node-java 0.12.0

  1. We run your code, the test results are same on MacOS and Linux.

    2020/01/01

    ja_JP

    81

    81

  2. We run below code on MacOS and Linux.

Nodejs:

console.log(DateFormat.getDateInstanceSync(DateFormat.SHORT, new Locale("ja", "JP")).formatSync(new Date()))

Java:

System.out.println(DateFormat.getDateInstance(DateFormat.SHORT, new Locale("ja", "JP")).format(new Date()));

Four results (2 java + 2 nodejs) are same.

2020/02/17

Please give us your environments of MacOS like above.

@ahsaniqbalsidiqui

Oh, you’re right. Certainly node-java was referred to another JDK. This JDK is a small one generated using jlink. There may have been a problem with this generation method.

This is not an issue with Aspose. Thanks for the advice.

@furuta,
You are welcome.