Linq. formatting date errors


#1

Hi!

My template:
<<[dateTime]:“yyyy.MM.dd”>>

Generation code:
import java.util.Date;
/…/
engine.getKnownTypes().add(Date.class);
engine.buildReport(document, new Date(), “dateTime”);

Error:
java.lang.IllegalArgumentException: Multiple decimal separators in pattern “yyyy.MM.dd”
at java.text.DecimalFormat.applyPattern(DecimalFormat.java:3339)
at java.text.DecimalFormat.applyPattern(DecimalFormat.java:3104)
at asposewobfuscated.zzK2.zzZk(Unknown Source)

I’ve tested it on Aspose.Words 18.5 и 17.9.

What am I doing wrong?


#2

@rubcs,

Thanks for your inquiry. After an initial test with the licensed latest version of Aspose.Words for Java i.e. 18.6, we were unable to reproduce this issue on our end. Please see input/output documents (Docs.zip (21.3 KB)) and try running the following code:

Document doc = new Document("D:\\Temp\\in.docx");

ReportingEngine engine = new ReportingEngine();
engine.getKnownTypes().add(Date.class);
engine.buildReport(doc, new Date(), "dateTime");

doc.save("D:\\Temp\\awjava-18.6.pdf");

#3

Thanks!
Unfortunately, I did all that. If in more detail:
Aspose.Words version: 18.6
code:

public static void main(String[] args) throws Exception {
    printProps("os.name", "java.runtime.version");
    Document doc = new Document("/home/pegoopik/aspose/format/in.docx");
    ReportingEngine engine = new ReportingEngine();
    engine.getKnownTypes().add(Date.class);
    engine.buildReport(doc, new Date(), "dateTime");//IllegalArgumentException
    doc.save("/home/pegoopik/aspose/format/out.docx");
}
private static void printProps(String... names) {
    for (String name : names)
        System.out.println(name.concat(" -> ").concat(System.getProperty(name)));
}

out:

os.name -> Linux
java.runtime.version -> 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11
Exception in thread "main" java.lang.IllegalArgumentException: Multiple decimal separators in pattern "yyyy.MM.dd"
	at java.text.DecimalFormat.applyPattern(DecimalFormat.java:3339)
	at java.text.DecimalFormat.applyPattern(DecimalFormat.java:3104)
	at asposewobfuscated.zzK0.zzZi(Unknown Source)
	at asposewobfuscated.zzBH.<init>(Unknown Source)
	at asposewobfuscated.zzOR.zzZ(Unknown Source)
	at asposewobfuscated.zzVS.zzW9(Unknown Source)
	at asposewobfuscated.zzOR.zzZ(Unknown Source)
	at asposewobfuscated.zzDF.zzZ(Unknown Source)
	at com.aspose.words.ReportingEngine.buildReport(Unknown Source)
	at com.aspose.words.ReportingEngine.buildReport(Unknown Source)
	at ru.bcs.printservice.DateFormatRunner.main(DateFormatRunner.java:15)

#4

@rubcs,

Please ZIP and upload your input Word document you are getting this problem with here for testing. We will investigate the issue on our end and provide you more information.


#5

I downloaded your in.docx file by reference https://forum.aspose.com/uploads/discourse_instance3/16731
And I used it as a template.


#6

@rubcs,

I am afraid, we are still unable to reproduce this issue on our end on Ubuntu OS. Please create a simple Java application that helps us to reproduce this issue on our end and attach it here for further testing.


#7

Hi,

Test in gitlab:
DateFormatTest.java

On my workstation and on our server this test throws an IllegalArgumentException.
On the gitlab server this test runs successfully:
gitlab ci pipline

Wrerein if I add -Duser.language=eng in java options on my workstation - the test is also successful!

But this option is not suitable.


#8

@rubcs,

Thanks for the additional information. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSJAVA-1848. We will further look into the details of this problem and will keep you updated on the status of this issue. We apologize for your inconvenience.


#9

Hi, did the fix come out at 18.8?


#10

@rubcs,

Unfortunately, your issue (WORDSJAVA-1848) is not resolved yet. We will inform you via this thread as soon as this issue is resolved. We apologize for any inconvenience.


#11

The issues you have found earlier (filed as WORDSJAVA-1848) have been fixed in this Aspose.Words for .NET 18.9 update and this Aspose.Words for Java 18.9 update.