You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Mike Thomsen <mi...@gmail.com> on 2018/12/11 16:31:01 UTC

Date format bug in 1.8 that got fixed in 1.9

FYI, ran into this bug. It's fixed in 1.9.0-SNAPSHOT

1. Declare an avro timestamp-millis field.
2. Try to convert to string with format(/fieldName, "yyyy-MM-dd")

Get an exception saying DataTypeUtils cannot convert java.sql.Timestamp to
java.sql.Date

This is the line that fixed it, FWIW, in 1.9.0-SNAPSHOT (sharing so others
can give it a quick review):

if (value instanceof java.util.Date) {
    java.util.Date _temp = (java.util.Date)value;
    return new Date(_temp.getTime());
}

Re: Date format bug in 1.8 that got fixed in 1.9

Posted by Mike Thomsen <mi...@gmail.com>.
Forgot to mention that there is a workaround that worked for me:

format(toDate(toString(/fieldName, "UTF-8"), "yyyy-MM-dd HH:mm:ss"),
"yyyy-MM-dd HH:mm:ss")

On Tue, Dec 11, 2018 at 11:31 AM Mike Thomsen <mi...@gmail.com>
wrote:

> FYI, ran into this bug. It's fixed in 1.9.0-SNAPSHOT
>
> 1. Declare an avro timestamp-millis field.
> 2. Try to convert to string with format(/fieldName, "yyyy-MM-dd")
>
> Get an exception saying DataTypeUtils cannot convert java.sql.Timestamp to
> java.sql.Date
>
> This is the line that fixed it, FWIW, in 1.9.0-SNAPSHOT (sharing so others
> can give it a quick review):
>
> if (value instanceof java.util.Date) {
>     java.util.Date _temp = (java.util.Date)value;
>     return new Date(_temp.getTime());
> }
>
>
>