Groovy web console

subscribe to the feed Subscribe
to this
site

groovy timestamp

Published 1 month ago by Anonymous
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
import java.text.SimpleDateFormat;
import java.util.Date;

def logtime = logs.logtime[-1] //get the last timestamp

        SimpleDateFormat date = new SimpleDateFormat("HH:mm:ss") //changes the format so that only time is shown in a string
        String current = date.format(new Date()) // fetches the current time
        String old = date.format(logtime()) // fetches the last available timestamp in log in proper format
        if (current - old >= 00:20:00) {          //condition to check if log time is lagging behind more than 20 mins. 
         println("The time diff is more than 20 mins, please send a mail to support team"); 
      }