Skip to content

GlobalConfiguration.DATE_TIME_FORMAT incompatible with GlobalConfiguration.DATE_TIME_IMPLEMENTATION #1050

Closed

Description

@vic0824

ArcadeDB Version: 23.3.1

JDK Version: openjdk version "11.0.12" 2021-07-20 LTS

OS: CentOS release 6.10 (Final)

Expected behavior

It is possible to use the LocalDateTime implementation and a DateTimeFormat that uses microseconds, like this:

GlobalConfiguration.DATE_TIME_IMPLEMENTATION.setValue(java.time.LocalDateTime.class);
GlobalConfiguration.DATE_TIME_FORMAT.setValue("yyyy-MM-dd'T'HH:mm:ss.SSSSSS");

Actual behavior

GlobalConfiguration.DATE_TIME_FORMAT expects a date time format using Java SimpleDateFormat syntax, which cannot handle microseconds.
Specifying a format using microseconds causes an exception (Studio cannot display the types in the db and cannot perform any query)

Steps to reproduce

  • Set
GlobalConfiguration.DATE_TIME_IMPLEMENTATION.setValue(java.time.LocalDateTime.class);
GlobalConfiguration.DATE_TIME_FORMAT.setValue("yyyy-MM-dd'T'HH:mm:ss.SSSSSS");
  • create an instance of ContextConfiguration
  • create a database called csrsdb
  • create some Document Types
  • start the ArcadeDB server passing the ContextConfiguration to the constructor
  • Log in to Studio
  • Verify that it shows the error: "Cannot execute command Illegal pattern character 'V'", which is returned by the server in response to the request: http://[URL]/api/v1/query/csrsdb
  • Inspect the ArcadeDB log and verify that it contains the following exception:
2023-04-23 08:57:06.191 INFO  [ArcadeDBServer] <ArcadeDB_0> Studio web tool available at http://cs2minipds-test:8080 <ArcadeDB_0> Error on command execution (PostQueryHandler)
java.lang.IllegalArgumentException: Illegal pattern character 'V'
        at java.base/java.text.SimpleDateFormat.compile(Unknown Source)
        at java.base/java.text.SimpleDateFormat.initialize(Unknown Source)
        at java.base/java.text.SimpleDateFormat.<init>(Unknown Source)
        at java.base/java.text.SimpleDateFormat.<init>(Unknown Source)
        at com.arcadedb.serializer.json.JSONObject.setDateFormat(JSONObject.java:275)
        at com.arcadedb.server.http.handler.AbstractHandler.createResult(AbstractHandler.java:195)
        at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:93)
        at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:92)
        at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:127)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
        at java.base/java.lang.Thread.run(Unknown Source)
  • note that the DATE_TIME_FORMAT was set to a pattern that does not contain the character 'V'

Recommendation

Use the DateTimeFormatter class of the java.time API instead of the SimpleDateFormat class of the java.Date API

Activity

  1. self-assigned this
    on Apr 24, 2023
  2. added this to the 23.4.1 milestone on Apr 24, 2023
  3. lvca commented on Apr 24, 2023

    @lvca
    Member

    Reproduced. The issue is with the JSONObject class that is still using the old SimpleDateFormat instead of DateTimeFormatter.

  4. added a commit that references this issue on Apr 25, 2023
  5. vic0824 commented on May 14, 2023

    @vic0824
    Author

    It still does not work with version 23.4.1.

    Using DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS")

    I get the following error when loading Studio: "Cannot execute command Pattern letter count must be 2: V"
    The console shows the following error message: "http://172.27.119.73:8080/api/v1/query/csrsdb: Failed to load resource: the server responded with a status of 400 (Bad Request)"
    and the arcadedb log file contains the following exception:

    <ArcadeDB_0> Error on command execution (PostQueryHandler)
    java.lang.IllegalArgumentException: Pattern letter count must be 2: V
            at java.base/java.time.format.DateTimeFormatterBuilder.parsePattern(Unknown Source)
            at java.base/java.time.format.DateTimeFormatterBuilder.appendPattern(Unknown Source)
            at java.base/java.time.format.DateTimeFormatter.ofPattern(Unknown Source)
            at com.arcadedb.serializer.json.JSONObject.setDateFormat(JSONObject.java:277)
            at com.arcadedb.server.http.handler.AbstractHandler.createResult(AbstractHandler.java:195)
            at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:93)
            at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:92)
            at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:127)
            at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
            at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
            at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
            at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
            at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
            at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
            at java.base/java.lang.Thread.run(Unknown Source)
    
  6. reopened this on May 14, 2023
  7. lvca commented on May 14, 2023

    @lvca
    Member

    How did you set the database date format?

  8. vic0824 commented on May 14, 2023

    @vic0824
    Author

    Oops, my bad.
    I had set GlobalConfiguration.DATE_TIME_FORMAT.setValue = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS")
    instead of GlobalConfiguration.DATE_TIME_FORMAT.setValue = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS"

    It works as expected.

  9. lvca commented on May 14, 2023

    @lvca
    Member

    Great, closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions