Wrong ISO-Datetime format in Tasklist's GraphQL API?

Hi,

it seems that the Camunda 8 tasklist’s GraphQL API is not formatting datetimes correctly.

If I retrieve the “creationTime” of the tasklist via the GraphQL API using:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZC....." -d '{"query": "{tasks(query:{}){name creationTime}}"}' https://bru-2.tasklist.camunda.io:443/76f0bca2-b5b7......../graphql

I get a result like:

{
  "data" : {
    "tasks" : [ {
      "name" : "My Task",
      "creationTime" : "2022-07-27T12:04:44.942+0000"
    } ]
  }
}

If I try to parse the “creationTime” using the standard Java API Instant.parse(…) I get a parse error: java.time.format.DateTimeParseException: Text '2022-07-27T12:04:44.942+0000' could not be parsed at index 23

Looking on various resources on the internet it seems that there is a colon missing in the timezone offset, i.e. “+00:00” instead of “+0000”

Is there a reason why tasklist’s GraphQL API is not returning the standard ISO format?

Kind regards
Tobias

This succeeds as a workaround:

OffsetDateTime.parse(datetime, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX")).toInstant()

but the format of the response still seems unusual to me.

Any hints?

2 Likes

Hi @tobiasschaefer ,

Tasklist uses Elasticsearch date_time format:

image

If you use this it should work:

  @Test
  public void testFormat(){
    final String dateString = "2022-07-27T12:04:44.942+0000";
    DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse(dateString);
  }

But I think this is a good point. I agree it would be nice if we provide the date time in a more standard way.
I’ll discuss this issue in the team.

Regards

2 Likes