Welcome Guest! Log in

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.

Please Log in or Create an account to join the conversation.