1
0
-1

Dear Mister/ Madam,

 

I have a date picker with (yyyy/MM/dd) format, but the deadline format of joget is (dd/MM/yyyy). So, I have tried to change the format of the date picker with the use of a Javascript (confirmed that it is work), in order to match the deadlines format, but the process does not work, while the log file is giving the following error massage

“The result of expression var d =newjava.text.SimpleDateFormat('dd/MM/yyyy'); d.parse(returnDate2); can't be evaluated - error message=Wrapped java.text.ParseException: Unparseable date: "" (#1)”

in which the “returnDate2” is my workflow variable which contains my formatted deadline.

 

What am I doing wrong or there is a better way to solve this problem without changing my date picker format?             

 

Best regards

  1. Ashutosh Tripathi

    Can't you use the 'Data Format' property of your datepicker to save the date in the format you like and use the 'Display Format' property for the users to see?

CommentAdd your comment...

3 answers

  1.  
    1
    0
    -1

    I have used the (yyyy/MM/dd) data-format, because the (dd/MM/yyyy) does not work properly when sorting the list (since it sorts the list based on the date first).

    So I have used the (dd/MM/yyyy) as a display-format, but the workflow variable of the date picker, takes the data-format (not the display-format) and as a result the deadlines are not working properly.

     

    I can implement the suggested solution, only if there is a way to sort a (dd/MM/yyyy) format based on the year first.

    Change the format just before you pass it to the deadline.

    1. Get the Date Formatter plugin https://marketplace.joget.org/jw/web/userview/mp/mpp/_/vad?id=date_formatter_hash_variable-1
    2. Put a Tool before the activity with deadline inside in process builder.

    3. Map the tool to Bean Shell Tool.

    4. Enter the code into it.
      Change this code accordingly. In this code, the workflow variable "timer" holds yyyy-MM-dd value.
      It will be changed to dd-MM-yyyy and set back into itself.
      (In your case, change "timer" to "returnDate2")

      import org.joget.workflow.model.service.*;
       
      WorkflowManager wm = (WorkflowManager) pluginManager.getBean("workflowManager");
      wm.activityVariable(workflowAssignment.getActivityId(),"timer", " #dateFormatter.{{variable.timer}}.yyyy-MM-dd&dd/MM/yyyy#");
      CommentAdd your comment...
    1.  
      1
      0
      -1

      Dear Mister/ Madam,

       

      Thank you for your answers.


      I have used the (yyyy/MM/dd) data-format, because the (dd/MM/yyyy) does not work properly when sorting the list (since it sorts the list based on the date first).
      So I have used the (dd/MM/yyyy) as a display-format, but the workflow variable of the date picker, takes the data-format (not the display-format) and as a result the deadlines are not working properly.

      I can implement the suggested solution, only if there is a way to sort a (dd/MM/yyyy) format based on the year first.


      Best regards

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi, as suggested in the comments the page Using Date Formatter, Date Filter and Date Range Filter might be helpful.

          CommentAdd your comment...