java-sdk icon indicating copy to clipboard operation
java-sdk copied to clipboard

DateTimeParseException: Unable to parse timestamp with timezone and microseconds in getJob test

Open humblefool25 opened this issue 5 months ago • 2 comments

Image

Description

Running mvn clean install with Java 11 fails during the following test:

DaprPreviewClientGrpcTest.getJobShouldReturnResponseWithDueTimeSetWhenResponseHasDueTime

The error is due to parsing an ISO-8601 datetime string with microseconds and a timezone offset.


Steps to Reproduce

  1. Set Java version:

    export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
    java -version
    

    Output:

    openjdk version "11.0.27" 2025-04-15
    
  2. Run:

    mvn clean install
    
  3. Observe the test failure.


Error Log


-------------------------------------------------------------------------------
Test set: io.dapr.client.DaprPreviewClientGrpcTest
-------------------------------------------------------------------------------
Tests run: 39, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.393 s 

Environment

Setting Value
Java Version OpenJDK 11.0.27 (Ubuntu)
Maven Version mvn --version (latest)
Dapr SDK Version 1.16.0-SNAPSHOT
OS Ubuntu 22.04
Command mvn clean install

Root Cause

The timestamp string:

2025-07-12T21:30:10.720884+05:30

contains both microseconds and a timezone offset, which Instant.parse() does not support.
Instant.parse() expects the datetime in UTC format like:

2025-07-12T21:30:10.720884Z

Suggested Fix

Replace:

Instant.parse(dateString);

With:

OffsetDateTime.parse(dateString, DateTimeFormatter.ISO_OFFSET_DATE_TIME).toInstant();

This change will correctly parse the datetime string with offset and microseconds.


humblefool25 avatar Jul 12 '25 16:07 humblefool25

Hello @humblefool25 , I checked this issue and the problem is you are running with java11. In order to compile it properly you need to have java17, you can find it the instructions here and here.

Even tough we are setting the compatibily mode to java11 the project need to be built with java17

We could fix it as you proposed, but not sure compiling it with java11 could have another potential issues.

javier-aliaga avatar Jul 15 '25 14:07 javier-aliaga

I think we can close this issue @dapr/maintainers-java-sdk

salaboy avatar Aug 27 '25 06:08 salaboy