cancel
Showing results for 
Search instead for 
Did you mean: 

MVEL + update + specific date : Update a date field to a specific date?

milonette_
Star Collaborator
Star Collaborator

Hello,

I would like to know how to update a date field to a specific date as 12-12-2014 ?

I try to use MVEL fn.date() but failed...

thanks

1 ACCEPTED ANSWER

milonette_
Star Collaborator
Star Collaborator

Hello Me,

I found this things:

  1. The java object for Date is java.util.Calendar
  2. The class that is used for Fn.calendar is org.nuxeo.ecm.automation.features.PlatformFunctions.calendar(java.util.Date) but it's not needed there

This is the code that I did :

java.util.Calendar cal= java.util.Calendar.getInstance(java.util.Locale.getDefault()) ;
//warning calendar month starts at 0 (=JANUARY), 1(=FEBRUARY)...
cal.set(2999, 11, 31);
WorkflowVariables["birthDate"]=cal;

Info about calendar:=> result is 2999-12-31

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
System.err.println(format.format(cal.getTime()));

View answer in original post

1 REPLY 1

milonette_
Star Collaborator
Star Collaborator

Hello Me,

I found this things:

  1. The java object for Date is java.util.Calendar
  2. The class that is used for Fn.calendar is org.nuxeo.ecm.automation.features.PlatformFunctions.calendar(java.util.Date) but it's not needed there

This is the code that I did :

java.util.Calendar cal= java.util.Calendar.getInstance(java.util.Locale.getDefault()) ;
//warning calendar month starts at 0 (=JANUARY), 1(=FEBRUARY)...
cal.set(2999, 11, 31);
WorkflowVariables["birthDate"]=cal;

Info about calendar:=> result is 2999-12-31

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
System.err.println(format.format(cal.getTime()));