cancel
Showing results for 
Search instead for 
Did you mean: 

Add minutes to current date time using groovy

SOLVED
Highlighted
Regular 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

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Add minutes to current date time using groovy

@Deepika_Lalam 

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"))}

 



Regards,
Rao.

View solution in original post

1 REPLY 1
Highlighted
Community Hero

Re: Add minutes to current date time using groovy

@Deepika_Lalam 

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"))}

 



Regards,
Rao.

View solution in original post

New Here?
Join us and watch the welcome video:
Top Kudoed Authors