I've used variable my_date with Prompt as Date Input setting, provided todays date (2021-05-31). Then I've tried to get that date in different format, using vars.get().asDate() and uitl.formatDate(), which gave me previous day instead of current. Minimal working example code below. It's clearly connected with user/instance timezone but I'd like to avoid hardcoding "add 1 day" wherever we use date variables.
I've used variable my_date with Prompt as Date Input setting, provided todays date (2021-05-31). Then I've tried to get that date in different format, using vars.get().asDate() and uitl.formatDate(), which gave me previous day instead of current. Minimal working example code below. It's clearly connected with user/instance timezone but I'd like to avoid hardcoding "add 1 day" wherever we use date variables.
groovy:
my_date = vars.get("my_date")
logger.info("To string: " + my_date.toString())
// To string: 2021-05-31 +0200
logger.info("Date with underscores: " + util.formatDate(my_date.asDate(), "yyyy_MM_dd"))
// Date with underscores: 2021_05_30
logger.info("Full datetime object: " + util.formatDate(my_date.asDate(), "yyyy-MM-dd, HH:mm:SS Z"))
// Full datetime object: 2021-05-30, 22:00:00 +0000