Issue
From a Jenkins build it will return an output as Change sets: (1901) ----$ Kivi "comment about the update done" 17-Dez-2021 02:10 PM
I need to fetch only the date and time from this line 17-Sep-2020 02:15 PM
and return an output in timezone format as yyyyMMddHHmmssSSS using Groovy. Have anyone tried with this ? Can someone provide some inputs regarding the same. Thank you !
Solution
Let's say you have a string
variable initialDate
containing 17-Sep-2020 02:15 PM
, you can do:
initialDate = '17-Sep-2020 02:15 PM'
date = new Date(initialDate).format('yyyyMMddHHmmssSSS')
println date // display 20200917141500000
Answered By - Brahim Ben Amira
Answer Checked By - Cary Denson (JavaFixing Admin)