Repository navigation
Closed
Milestone
Description
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
lvca commentedon Apr 24, 2023
Reproduced. The issue is with the JSONObject class that is still using the old SimpleDateFormat instead of DateTimeFormatter.
fix: fixed issue managing dates with JSON
vic0824 commentedon May 14, 2023
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:
fix: added detailed message on the date format in case of error
lvca commentedon May 14, 2023
How did you set the database date format?
vic0824 commentedon May 14, 2023
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.
lvca commentedon May 14, 2023
Great, closing it.
fix: fixed issue managing dates with JSON
fix: added detailed message on the date format in case of error
build(deps): update testcontainers requirement from >=4.14.2 to >=4.1…
build(deps): bump the github-actions group across 1 directory with 6 …