Here’s my script:
system.date.format(system.date.now(), "YYYY-MM-dd")
And the output I get 2021-12-28
Use yyyy