Forum Discussion

MD01's avatar
MD01
Occasional Contributor
8 years ago

adding hours to the present date with groovy

Hi Following is my code to add days to the present date, How can i add hours to the present date instead of days      def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def toda...
  • nmrao's avatar
    8 years ago

    MD01,

    Here your go:

     

    Looks like this is your question in Stackoverflow which happened to answer there already.

    It would be easy if you use time category as shown below. 

     

    use(groovy.time.TimeCategory) {
        def halfHourFromNow = new Date() + 2.hour 
        log.info halfHourFromNow.format("yyyy-MM-dd HH:mm:ss")
    }

    You can quickly check it online demo