Skip to content

Support Java 8 Dates in Job and Step Execution [BATCH-2590] #1014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue May 2, 2017 · 8 comments
Closed
Labels
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Philippe Marschall opened BATCH-2590 and commented

Currently all timestamps on JobExecution and StepExecution are of type java.util.Date. It would be cool if instead they could be directly a Java 8 Date Time API type, OffsetDateTime and ZonedDateTime are obvious candidates.
Ideally the data type of the corresponding database would be changed from TIMESTAMP to TIMESTAMP WITH TIME ZONE as well.


No further details from BATCH-2590

@ptahchiev
Copy link

Yep +1 here. And also consider changing the job parameter types to be java8 Date Time API.

@fmbenhassine fmbenhassine added has: votes Issues that have votes and removed status: waiting-for-triage Issues that we did not analyse yet labels Jan 26, 2021
@fmbenhassine fmbenhassine added this to the 5.0.0 milestone Jan 26, 2021
@javaHelper
Copy link

@benas - When Spring Batch 5.0.0 will be ready?

@fmbenhassine
Copy link
Contributor

@javaHelper It depends on the release date of SF 6, but it is expected for the upcoming Fall.

@fmbenhassine fmbenhassine modified the milestones: 5.0.0, 5.0.0-M6 Aug 31, 2022
@fmbenhassine fmbenhassine modified the milestones: 5.0.0-M6, 5.0.0-M7 Sep 21, 2022
@fmbenhassine fmbenhassine modified the milestones: 5.0.0-M7, 5.0.0-M8 Oct 4, 2022
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Oct 11, 2022
This is an attempt to change the data type of startTime, endTime,
createTime and lastUpdated in JobExecution and StepExecution to
OffsetDateTime, which corresponds to the SQL type TIMESTAMP WITH TIME ZONE.

However, the type `TIMESTAMP WITH TIME ZONE` does not seem to be supported
by some databases (or their drivers). Here is a quick list of issues related
to this change:

### MySQL:

```
Unsupported SQL type: TIMESTAMP_WITH_TIMEZONE
```

At `JdbcJobExecutionDao` (L173 as of 2b258d1)

```
getJdbcTemplate().update(getQuery(SAVE_JOB_EXECUTION), parameters,
   new int[] { Types.BIGINT, Types.BIGINT, Types.TIMESTAMP_WITH_TIMEZONE,
   Types.TIMESTAMP_WITH_TIMEZONE, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
   Types.INTEGER, Types.TIMESTAMP_WITH_TIMEZONE, Types.TIMESTAMP_WITH_TIMEZONE });
```

### DB2:

```
[jcc][1091][10417][4.31.10] Invalid data conversion: Parameter instance 2022-10-11T15:21:26.905406+02:00 is invalid for the requested conversion. ERRORCODE=-4461, SQLSTATE=42815
```

### Derby:

```
ERROR 22005: An attempt was made to get a data value of type 'TIMESTAMP' from a data value of type '2014'.
```

---

Adding custom code for specific DB providers in various DAOs is not an option
for the time being.

For all these reasons, it was decided to defer the implementation of this
feature to future release.

Issue spring-projects#1014
@fmbenhassine
Copy link
Contributor

While evaluating the change of timestamp fields to OffsetDateTime, several issues popped up, see #4209.

For this reason, we have decided to change the type from java.util.Date to java.time.LocalDateTime for now, and defer the feature of making those fields timezone aware to a future release.

@uyw4687
Copy link

uyw4687 commented Mar 12, 2024

@fmbenhassine Hello, it seem the datatype is still Date, not LocalDateTime on the API(JobParametersBuilder.addDate).
Is this issue still ongoing or removed? I can contribute if you allow me to. Thanks.

@uyw4687
Copy link

uyw4687 commented Mar 12, 2024

It's off-topic, but is there any rationale to exclude addBoolean on the JobParametersBuilder?

@davidkarlsen
Copy link
Contributor

@fmbenhassine Hello, it seem the datatype is still Date, not LocalDateTime on the API(JobParametersBuilder.addDate). Is this issue still ongoing or removed? I can contribute if you allow me to. Thanks.

It's there?

new JobParametersBuilder()
            .addLocalDateTime(Config.JOB_PARAMETER_NAME_TO_DATE, LocalDateTime.now())

@uyw4687
Copy link

uyw4687 commented Mar 13, 2024

@davidkarlsen Sorry, I was using spring boot 2. I checked it from code.
How about addBoolean? Should I make a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants