How to convert the date from bonita format to yyyy/mm/dd?


Hi ,

i would like to convert the date that i retrieve with the widget to this format YYYY/mm/dd and then save it into mysql database



Submitted by claz08 on Mon, 10/05/2015 - 21:38

I have created this code:

`import java.text.SimpleDateFormat;
import java.util.Date;

public class exemple {
      public static void main(String[ ] arg) {

java.util.Date date = ${date_local};
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String format = formatter.format(date);

Then what i want to do is retrieve the date that the user has selected and then convert its format from this Mon Oct 05 21:11:32 2015 or this DD/MM/YYYY to this YYYY/MM/DD.

i don't know where i can put this code into my workflow in order to do it .

I'm doing this because i need the dates with this format :yyyy/mm/dd , in order to put in a insert query , because my database use this format


Submitted by claz08 on Tue, 10/06/2015 - 17:21

Somebody has any idea?

1 answer


First, you are probably using Java 8 - in which case drop the and use the new java.time imports. Much better for date and time manipulation.

See here for more information:

Here you can then use DateTimeFormatter.ofPattern("YYYY/MM/DD") construct.

I wouldn't do the conversion in the form, but only in the process stream before the update to the database using a service task (or the task output operation). Or in the SQL statement itself, such as

  1. INSERT INTO custorder VALUES ('Kevin','yes', STR_TO_DATE('1-01-2012', '%d-%m-%Y'));

This is fro PHP so change the formats and variables as necessary...



Submitted by claz08 on Tue, 10/06/2015 - 18:01

i have created this mysql query , but didn't work:

INSERT INTO it.documentation ('james','a','b', STR_TO_DATE('${fecha}','%Y-%m-%d')

where i have the wrong?

I think that the wrong is in variable ${fecha}.

Submitted by claz08 on Tue, 10/06/2015 - 18:49

i have reviewed the variable that contain the date, that the user has selected, and i see that it saved with this format : 1 de octubre de 2015., this is the reason that why didn't work.

I have changed this format ,but when i execute the process , the format is the same, and finally it didn't work the insert query .

Submitted by Sean McP on Tue, 10/06/2015 - 19:50

Have you tried a hardcoded version of the insert first, with a real date? Try that. Then work on the Bonita version. Use the MySQL Workbench to prove that the SQL works.

Submitted by claz08 on Tue, 10/06/2015 - 20:19

I have tried the insert query with workbench and it worked well .

as yo i say in the previous post , the problem is with the variable that are there in the insert query , because i can see that its value is : 10 october...etc , and not is 2015-01-01 , for example.

so ..
How i can change the format of date variable .?

Submitted by pinerodanie_1404393 on Fri, 07/12/2019 - 09:44

Tengo el mismo problema alguien lo resolvio?