Skip to content

Instantly share code, notes, and snippets.

@themarcelor
Created January 13, 2021 22:44
Show Gist options
  • Save themarcelor/f7f7eceb7b2a70d2a72f6a655c1c5cdb to your computer and use it in GitHub Desktop.
Save themarcelor/f7f7eceb7b2a70d2a72f6a655c1c5cdb to your computer and use it in GitHub Desktop.
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import hudson.Util;
currentTime = new Date().getTime()/1000 as Integer
Date date = new Date(currentTime * 1000L);
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");
String formatted = format.format(date);
println(formatted)
//def jenkinsTimeMillis = System.currentTimeMillis()
def jenkinsTimeMillis = (new Date().getTime()) + 3600000
//println(jenkinsTimeMillis)
Date date2 = new Date(jenkinsTimeMillis);
DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");
String formatted2 = format2.format(date2);
println(formatted2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment