Forum Discussion

Punith_8's avatar
Punith_8
Occasional Contributor
9 years ago

Calculating days to a date

Hi,   I have a scenario where I need to add days which is stored in a variable to a date(YYYY-MM-DD) which again is stored in a variable. The way I try to add, it is concatenating with the date and...
  • nmrao's avatar
    nmrao
    9 years ago

    Does the below helps?

     

    import groovy.time.TimeCategory
    def pattern = 'yyyy-MM-dd'
    def dateString = '2015-09-29 17:31:54.5454000 -04:00'
    def b = new Date().parse(pattern,dateString)
    def c = 16  
    use (TimeCategory){   
        def a= b+ c.days   
        println a.format(pattern)
    }