Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1983#discussion_r126361121
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutSQL.java
 ---
    @@ -828,10 +833,50 @@ private void setParameter(final PreparedStatement 
stmt, final String attrName, f
                         stmt.setBigDecimal(parameterIndex, new 
BigDecimal(parameterValue));
                         break;
                     case Types.DATE:
    -                    stmt.setDate(parameterIndex, new 
Date(Long.parseLong(parameterValue)));
    +                    Date date;
    +
    +                    if (valueFormat.equals("")) {
    +                        if(LONG_PATTERN.matcher(parameterValue).matches()){
    +                            date = new 
Date(Long.parseLong(parameterValue));
    +                        }else {
    +                            String dateFormatString = "yyyy-MM-dd";
    +                            if (!valueFormat.isEmpty()) {
    +                                dateFormatString = valueFormat;
    +                            }
    +                            SimpleDateFormat dateFormat = new 
SimpleDateFormat(dateFormatString);
    +                            java.util.Date parsedDate = 
dateFormat.parse(parameterValue);
    +                            date = new Date(parsedDate.getTime());
    +                        }
    +                    } else {
    +                        final DateTimeFormatter dtFormatter = 
getDateTimeFormatter(valueFormat);
    +                        LocalDate parsedDate = 
LocalDate.parse(parameterValue, dtFormatter);
    +                        date = new 
Date(Date.from(parsedDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()).getTime());
    +                    }
    +
    +                    stmt.setDate(parameterIndex, date);
                         break;
                     case Types.TIME:
    -                    stmt.setTime(parameterIndex, new 
Time(Long.parseLong(parameterValue)));
    +                    Time time;
    +
    +                    if (valueFormat.equals("")) {
    +                        if 
(LONG_PATTERN.matcher(parameterValue).matches()) {
    +                            time = new 
Time(Long.parseLong(parameterValue));
    +                        } else {
    +                            String timeFormatString = "HH:mm:ss.SSS";
    +                            if (!valueFormat.isEmpty()) {
    --- End diff --
    
    Same as DATE, this won't be true.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to