diff --git a/spring-cloud-task-samples/batch-events/pom.xml b/spring-cloud-task-samples/batch-events/pom.xml
index de34c641..c415e5a2 100644
--- a/spring-cloud-task-samples/batch-events/pom.xml
+++ b/spring-cloud-task-samples/batch-events/pom.xml
@@ -81,6 +81,10 @@
org.hsqldb
hsqldb
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+
org.springframework.cloud
spring-cloud-stream
diff --git a/spring-cloud-task-samples/batch-events/src/test/java/io/spring/cloud/BatchEventsApplicationTests.java b/spring-cloud-task-samples/batch-events/src/test/java/io/spring/cloud/BatchEventsApplicationTests.java
index 9eca1502..556aa69a 100644
--- a/spring-cloud-task-samples/batch-events/src/test/java/io/spring/cloud/BatchEventsApplicationTests.java
+++ b/spring-cloud-task-samples/batch-events/src/test/java/io/spring/cloud/BatchEventsApplicationTests.java
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.junit.jupiter.api.Tag;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -54,6 +55,7 @@ public class BatchEventsApplicationTests {
@BeforeEach
public void setup() {
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ objectMapper.registerModule(new JavaTimeModule());
}
@AfterEach
diff --git a/spring-cloud-task-stream/pom.xml b/spring-cloud-task-stream/pom.xml
index 198db76e..7d093406 100644
--- a/spring-cloud-task-stream/pom.xml
+++ b/spring-cloud-task-stream/pom.xml
@@ -102,5 +102,11 @@
assertj-core
test
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+ test
+ true
+
diff --git a/spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/JobExecutionEvent.java b/spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/JobExecutionEvent.java
index 43051c59..e9d45bc2 100644
--- a/spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/JobExecutionEvent.java
+++ b/spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/JobExecutionEvent.java
@@ -16,10 +16,10 @@
package org.springframework.cloud.task.batch.listener.support;
+import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -49,13 +49,13 @@ public class JobExecutionEvent extends Entity {
private BatchStatus status = BatchStatus.STARTING;
- private Date startTime = null;
+ private LocalDateTime startTime = null;
- private Date createTime = new Date(System.currentTimeMillis());
+ private LocalDateTime createTime = LocalDateTime.now();
- private Date endTime = null;
+ private LocalDateTime endTime = null;
- private Date lastUpdated = null;
+ private LocalDateTime lastUpdated = null;
private ExitStatus exitStatus = new ExitStatus(new org.springframework.batch.core.ExitStatus("UNKNOWN"));
@@ -94,19 +94,19 @@ public class JobExecutionEvent extends Entity {
return this.jobParameters;
}
- public Date getEndTime() {
+ public LocalDateTime getEndTime() {
return this.endTime;
}
- public void setEndTime(Date endTime) {
+ public void setEndTime(LocalDateTime endTime) {
this.endTime = endTime;
}
- public Date getStartTime() {
+ public LocalDateTime getStartTime() {
return this.startTime;
}
- public void setStartTime(Date startTime) {
+ public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
@@ -197,14 +197,14 @@ public class JobExecutionEvent extends Entity {
/**
* @return the time when this execution was created.
*/
- public Date getCreateTime() {
+ public LocalDateTime getCreateTime() {
return this.createTime;
}
/**
* @param createTime creation time of this execution.
*/
- public void setCreateTime(Date createTime) {
+ public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
@@ -213,7 +213,7 @@ public class JobExecutionEvent extends Entity {
* JobRepository.
* @return Date representing the last time this JobExecution was updated.
*/
- public Date getLastUpdated() {
+ public LocalDateTime getLastUpdated() {
return this.lastUpdated;
}
@@ -221,7 +221,7 @@ public class JobExecutionEvent extends Entity {
* Set the last time this {@link JobExecution} was updated.
* @param lastUpdated The date the {@link JobExecution} was updated.
*/
- public void setLastUpdated(Date lastUpdated) {
+ public void setLastUpdated(LocalDateTime lastUpdated) {
this.lastUpdated = lastUpdated;
}
diff --git a/spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/StepExecutionEvent.java b/spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/StepExecutionEvent.java
index 057c7f70..a0416fde 100644
--- a/spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/StepExecutionEvent.java
+++ b/spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/StepExecutionEvent.java
@@ -16,7 +16,7 @@
package org.springframework.cloud.task.batch.listener.support;
-import java.util.Date;
+import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -55,11 +55,11 @@ public class StepExecutionEvent extends Entity {
private long writeSkipCount = 0;
- private Date startTime = new Date(System.currentTimeMillis());
+ private LocalDateTime startTime = LocalDateTime.now();
- private Date endTime = null;
+ private LocalDateTime endTime = null;
- private Date lastUpdated = null;
+ private LocalDateTime lastUpdated = null;
private ExecutionContext executionContext = new ExecutionContext();
@@ -147,7 +147,7 @@ public class StepExecutionEvent extends Entity {
* Returns the time that this execution ended.
* @return the time that this execution ended
*/
- public Date getEndTime() {
+ public LocalDateTime getEndTime() {
return this.endTime;
}
@@ -155,7 +155,7 @@ public class StepExecutionEvent extends Entity {
* Sets the time that this execution ended.
* @param endTime the time that this execution ended
*/
- public void setEndTime(Date endTime) {
+ public void setEndTime(LocalDateTime endTime) {
this.endTime = endTime;
}
@@ -227,7 +227,7 @@ public class StepExecutionEvent extends Entity {
* Gets the time this execution started.
* @return the time this execution started
*/
- public Date getStartTime() {
+ public LocalDateTime getStartTime() {
return this.startTime;
}
@@ -235,7 +235,7 @@ public class StepExecutionEvent extends Entity {
* Sets the time this execution started.
* @param startTime the time this execution started
*/
- public void setStartTime(Date startTime) {
+ public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
@@ -357,15 +357,15 @@ public class StepExecutionEvent extends Entity {
/**
* @return the Date representing the last time this execution was persisted.
*/
- public Date getLastUpdated() {
+ public LocalDateTime getLastUpdated() {
return this.lastUpdated;
}
/**
* Set the time when the StepExecution was last updated before persisting.
- * @param lastUpdated the {@link Date} the StepExecution was last updated.
+ * @param lastUpdated the {@link LocalDateTime} the StepExecution was last updated.
*/
- public void setLastUpdated(Date lastUpdated) {
+ public void setLastUpdated(LocalDateTime lastUpdated) {
this.lastUpdated = lastUpdated;
}
diff --git a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/EventListenerTests.java b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/EventListenerTests.java
index f79f2b3d..b8cd9500 100644
--- a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/EventListenerTests.java
+++ b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/EventListenerTests.java
@@ -23,6 +23,7 @@ import java.util.UUID;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -78,6 +79,8 @@ public class EventListenerTests {
@BeforeEach
public void beforeTests() {
+ objectMapper.registerModule(new JavaTimeModule());
+
this.applicationContext = new SpringApplicationBuilder()
.sources(TestChannelBinderConfiguration.getCompleteConfiguration(BatchEventsApplication.class))
.web(WebApplicationType.NONE).build().run();
diff --git a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java
index 0def2faa..87588b0b 100644
--- a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java
+++ b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java
@@ -16,6 +16,7 @@
package org.springframework.cloud.task.batch.listener;
+import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
@@ -217,7 +218,7 @@ public class JobExecutionEventTests {
@Test
public void testGetterSetters() {
- Date date = new Date();
+ LocalDateTime date = LocalDateTime.now();
JobExecutionEvent jobExecutionEvent = new JobExecutionEvent();
jobExecutionEvent.setLastUpdated(date);
assertThat(jobExecutionEvent.getLastUpdated()).isEqualTo(date);
diff --git a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/StepExecutionEventTests.java b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/StepExecutionEventTests.java
index 2edadb91..68a268c6 100644
--- a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/StepExecutionEventTests.java
+++ b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/StepExecutionEventTests.java
@@ -16,7 +16,7 @@
package org.springframework.cloud.task.batch.listener;
-import java.util.Date;
+import java.time.LocalDateTime;
import org.junit.jupiter.api.Test;
@@ -124,7 +124,7 @@ public class StepExecutionEventTests {
@Test
public void testSettersGetters() {
StepExecutionEvent stepExecutionEvent = new StepExecutionEvent(getBasicStepExecution());
- Date date = new Date();
+ LocalDateTime date = LocalDateTime.now();
stepExecutionEvent.setLastUpdated(date);
assertThat(stepExecutionEvent.getLastUpdated()).isEqualTo(date);