UI Designer returns wrong date

Description

When you select a date in a Date Picker object, you expect the date will be the same you selected. But after the last update to 7.3.0, the Date Picker widget is using UTC datetime to store its value, but it does not store the user TimeZone.

This leads to confusion, since if you select 2016-07-25 in Date Picker widget, it will store "2016-07-25 00:00:00 UTC" instead of "2016-07-25 00:00:00 GMT-0300" or even "2016-07-25" (since only the date part is important).

This appear to not be a problem, but when this value is sent back to Bonita Engine, Java interprets the date with the system timezone and it became "2016-07-24 21:00:00 GMT" (supposing your current timezone is GMT-3, as mine is).

Environment

Windows 7 Pro 64 bits, Bonita Studio 7.3.0 Tomcat Bundle (64 bit)

External Link

None

Workaround

I created a small Groovy script to convert UTC timezone to system's current timezone. I am using it to convert all dates that comes from UI Designer forms:

-----------------
import java.util.Date;
import java.util.TimeZone;

/**

  • Converts UTC date to system's current timezone.

  • Used to workaround UI Designer error introduced in version 7.3.0.
    *

  • @param utcdate UTC date to be modified.

  • @return Same date, but shifted to the system's current timezone.
    */
    public static Date UTCtoLocale(Date utcdate){
    long offset = TimeZone.getDefault().getOffset(utcdate.getTime());
    return new Date(utcdate.getTime() - offset);
    }
    -----------------

Status

Assignee

Antoine Mottier

Reporter

Diego Queiroz

Affects versions

7.3.0

Reference

BS-16042

Fix versions

Configure