Forum Discussion

Sandyapitester's avatar
Sandyapitester
Frequent Contributor
8 years ago

Date format - Need to get the current date from 10 date before date

Hi All,   Need to pass the request parameter value is current date from 10/20/30 days before   [ "25/08/2017"]   when ever execute the API need to pass the current date from 10/20/30 days befo...
  • groovyguy's avatar
    8 years ago

     You are subtracting too late. You need to subtract before you convert / format to a string. Try this:

     

    def today = new Date()
    def tenDaysAgo = today - 10
    log.info today.format("MM/dd/yyyy")
    log.info tenDaysAgo.format("MM/dd/yyyy")