senthkum
5 years agoContributor
Code to get the current date in yyyy-MM-dd format?
Hi Team,
I need the code to get the current date in yyyy-MM-dd format and I need to minus with the date with a week / Month and Year to send the valid response. Can anyone give me the code, so I can use it in dispatch style (Script) to send the response. I want the response as "2020-02-24" format.
I used thebelow code but the output is not has excepted.
def today = new Date()
def tenDaysAgo = today - 10
log.info today.format("yyyy-MM-dd")
log.info tenDaysAgo.format("yyyy-MM-dd")
Output:
Mon Feb 17 16:38:34 AEDT 2020:INFO:2020-02-17
Mon Feb 17 16:38:34 AEDT 2020:INFO:2020-02-07
Thanks
Senthil. M
- It is highly appreciated if you can update the thread after the suggestions.