Welcome Guest! Log in


The forum is in read only mode.
Due to some maintenance operations, stambia.org will be switched to read-only mode during the 13th November. It will be possible to read and download, but impossible to post on the forums or create new accounts. For any question please contact the support team.

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
Nicolas Verscheure created the topic: Working with dates in scripting
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.