Date format bug in 1.8 that got fixed in 1.9

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Date format bug in 1.8 that got fixed in 1.9

Mike Thomsen
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());
}
Reply | Threaded
Open this post in threaded view
|

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

Mike Thomsen
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 <[hidden email]>
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());
> }
>
>
>