Welcome Guest! Log in


The forum is in read only mode.
Stambia versions 2.x, 3.x, S17, S18, S19 and S20 are reaching End of Support January, 15th, 2024. Please consider upgrading to the supported Semarchy xDI versions. See Global Policy Support and the Semarchy Documentation.

The Stambia User Community is moving to Semarchy! All the applicable resources have already been moved or are currently being moved to their new location. Read more…

Topic-icon Question Working with dates in scripting

  • Nicolas Verscheure
  • Nicolas Verscheure's Avatar Topic Author
  • Offline
07 Dec 2014 21:21 - 07 Dec 2014 21:26 #1 by Nicolas Verscheure
Working with dates in scripting was created by Nicolas Verscheure
Working with metadata variable and refresh value from a sql connection can be heavy. Thus, if you want to manipulate dates and times, scripting is crafted for it.

Example 1 : get current date and 1 day

var now = new Date();
var nowIncrement = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);
format = new SimpleDateFormat('yyyyMMdd');
println('format = '+format.format(nowIncrement));

Example 2 : get current date time and substract 10 min

var now = new Date(java.lang.System.currentTimeMillis()-((10*60*1000)));
format = new SimpleDateFormat('yyyyMMdd HH:mm:ss');
println('date -10 min = '+format.format(now));

For more information, consult simple date format documentation . Remember : the value returned corresponds to the date and time of the server on which your process has been launched.
Last edit: 07 Dec 2014 21:26 by Nicolas Verscheure.