Deepika_Lalam
5 years agoRegular Visitor
Add minutes to current date time using groovy
To get the Current Date Time value, im using this:
${= Calendar.getInstance(TimeZone.getTimeZone('GMT')).format("yyyy-MM-dd'T'HH:mm:ss")}
which gives DateTime as 2020-02-05T22:07:34
I want to add 40 minutes to the current DateTime Value:
the expected result should be currentTime + 40 min. Which is: 2020-02-05T22:47:34
With Java 8, below should get you the time you needed in one liner
${= java.time.ZonedDateTime.now(java.time.ZoneId.of("GMT")).plusMinutes(40).format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))}