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-9592] External DB driver not working-MySQL #174

Merged
merged 1 commit into from Feb 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,7 +17,11 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
Expand Down Expand Up @@ -114,13 +118,23 @@ public Double convertToDouble(Object value) {
}

@Override
public Date convertToDate(Object value) {
try {
return value == null ? null : (Date) value;
} catch (ClassCastException e) {
throw new IllegalArgumentException("Not a java.util.Date: " + value + " (" + value.getClass().getName() + ")");
}
}
public Date convertToDate(Object value) {
if (value == null) {
return null;
} else if (value instanceof Date) {
return (Date) value;
} else if (value instanceof LocalDateTime) {
return Timestamp.valueOf((LocalDateTime) value);
} else if (value instanceof Number) {
return new Date(((Number) value).longValue());
} else {
try {
return DateFormat.getDateTimeInstance().parse(value.toString());
} catch (ParseException e) {
throw new IllegalArgumentException("Unable to convert " + value + " of type "+value.getClass()+" to date", e);
}
}
}

@Override
public String getTableSQL(SQLStatement<?> stmt) {
Expand Down