"Unparseable date" using Gen Classic Java Proxy with Java 11
search cancel

"Unparseable date" using Gen Classic Java Proxy with Java 11

book

Article ID: 268172

calendar_today

Updated On:

Products

Gen Gen - Run Time Distributed

Issue/Introduction

After compiling Classic Java Proxy with Java 11 JDK and running using Java 11 JVM/JRE the input date format "dd/mm/yyyy" (e.g. "13/06/2023") that is accepted with the previous Java 8 version of the proxy is not able to be parsed i.e.

Exception: java.text.ParseException: Unparseable date: "13/06/2023"

The behavior occurs when using the Classic Java Proxy i.e. the Standard Java Proxy does not show the problem.

 

Resolution

There have been some default date format changes in Java 9 and above. The Classic Java proxy uses Java class DateFormat in its generated code for the MainUI while the Standard Java proxy does not. This web page covers an example of how to restore the Java 8 behavior:  Stackoverflow > SimpleDateFormat .format() gives different results in Java8 vs. Java11
It advises adding the system property "-Djava.locale.providers=COMPAT,CLDR" to the JVM command line will give the same behavior as Java 8.

It was found that running the Java 11 compiled Classic Java Proxy using Java 11 JVM with the above additional system property allowed the same date format to be parsed that was accepted with the previous Java 8 compiled proxy. In fact, the COMPAT value was enough to enable successful parsing of the date format i.e. "-Djava.locale.providers=COMPAT".



This Classic Java proxy behavior change with Java 11 is purely due to a JVM default date format change and is not actually due to a Gen specific problem.

NOTE: In general, the required date format will be specific to the Locale on the local Windows machine - see #3 in Additional Information.

Additional Information

  1. Executing the Sample Java Proxy (Classic Style) Applications

  2. Another option instead of using the system property is to customize the generated code for the MainUI sample to use whatever date format is required. In general, the proxy sample programs are just samples that can be recoded by the Gen Developer as required.
    Tested changing the MainUI generated code (model.ief\proxy\java\src\server_manager\MainUI\server_managerUI.java) to use object SimpleDateFormat as follows:
    BEFORE: private DateFormat dateFormatter = DateFormat.getDateInstance();
    AFTER:    private DateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
    After rebuilding the proxy via the Build Tool using Java 11, the format of "13/06/2023" was accepted at runtime without needing to use the system property.

  3. The attached Java program code TestDateFormat.java can also be used to test the default outputs on a particular machine/locale from the objects DateFormat (used by the sample MainUI) and SimpleDateFormat (used by the sample Abean). An output of the system properties is also included which will show the current Locale in property "user.country".

Attachments

1687231089963__TestDateFormat.java get_app