From 605dfe82fbe1e95139508174174b9c6500397a2e Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Thu, 14 Mar 2024 10:25:05 +0100 Subject: [PATCH] [JBPM-10225] Considering time for Dates (#2397) --- .../jbpm/process/core/datatype/impl/type/ObjectDataType.java | 3 ++- .../jbpm/process/core/datatype/impl/ObjectDataTypeTest.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/ObjectDataType.java b/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/ObjectDataType.java index 11f7c85f63..d07f416609 100644 --- a/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/ObjectDataType.java +++ b/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/ObjectDataType.java @@ -137,11 +137,12 @@ private Optional getObjectFromClass(final Object value) { } private static Collection dateFormats = Arrays.asList(new SimpleDateFormat("yyyy-MM-ddHH:mm:ss"), + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"), new SimpleDateFormat("yyyy-MM-dd"), new SimpleDateFormat("HH:mm:ss"), DateFormat.getDateInstance(), DateFormat.getTimeInstance(), DateFormat.getDateTimeInstance()); - private Date parseDate(String toBeParsed) { + private static Date parseDate(String toBeParsed) { StringBuilder sb = new StringBuilder(); for (DateFormat dateFormat : dateFormats) { try { diff --git a/jbpm-flow/src/test/java/org/jbpm/process/core/datatype/impl/ObjectDataTypeTest.java b/jbpm-flow/src/test/java/org/jbpm/process/core/datatype/impl/ObjectDataTypeTest.java index 0b1461350a..5b3639fe79 100644 --- a/jbpm-flow/src/test/java/org/jbpm/process/core/datatype/impl/ObjectDataTypeTest.java +++ b/jbpm-flow/src/test/java/org/jbpm/process/core/datatype/impl/ObjectDataTypeTest.java @@ -23,6 +23,7 @@ import java.time.ZonedDateTime; import java.util.Date; +import org.assertj.core.api.InstanceOfAssertFactories; import org.jbpm.process.core.datatype.impl.type.ObjectDataType; import org.junit.Test; @@ -44,6 +45,8 @@ public void testReadValueDate() { assertThat(dateType.readValue("12:12:12")).isInstanceOf(Date.class); assertThat(dateType.valueOf("2012-02-02")).isInstanceOf(Date.class); assertThat(dateType.valueOf("12:12:12")).isInstanceOf(Date.class); + assertThat(dateType.valueOf("2016-01-11T01:06:32")).isInstanceOf(Date.class) + .asInstanceOf(InstanceOfAssertFactories.DATE).hasHourOfDay(1).hasMinute(6).hasSecond(32); assertThat(dateType.valueOf("pepe")).isInstanceOf(String.class); assertThatThrownBy(() -> dateType.readValue("pepe")).isInstanceOf(IllegalArgumentException.class); }