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)

Steps to reproduce

First assure your current system timezone is not UTC. Preferably your TimeZone should be less than zero (like GMT-3, GMT-4, etc.), this way the error is more evident.

  • Create a contract with a DATE field

  • Using the UI Designer, create a form to fill this contract using the Date Picker widget

  • Assign the value from this contract to a Local/Process Variable (or a Business Object)

  • Check the content of the assigned variable

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);
    }
    -----------------

External Link

None

Status

Assignee

Antoine Mottier

Reporter

Diego Queiroz

Reference

BS-16042

Components

Affects versions

7.3.0