Skip to content
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

[JBPM-10225] Considering time for Dates #2397

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ private Optional<Object> getObjectFromClass(final Object value) {
}

private static Collection<DateFormat> dateFormats = Arrays.asList(new SimpleDateFormat("yyyy-MM-ddHH:mm:ss"),
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"),
fjtirado marked this conversation as resolved.
Show resolved Hide resolved
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down
Loading