You can use DateTime
import org.joda.time.DateTime
Option 1 : with yyyyMMddHHmmss
DateTime.now().toString("yyyyMMddHHmmss")
Will give 20190205214430
Option 2 : yyyy-dd-M--HH-mm-ss
DateTime.now().toString("yyyy-dd-M--HH-mm-ss")
will give 2019-05-2--21-43-32