date.parse() method of groovy detects date DD and year yyyy correctly but is unable to detect the month as mmm.. As in
println new Date().parse("DD-MMM-yyyy", '22-MAR-2011')
yields output as
Sat Jan 22 00:00:00 GMT+05:30 2011
Why is the month march as MAR picked up as Jan? What can I do to make it detect the month in mmm format?
The problem is actualy that you are using
DD– that means day in yearCorrect way:
Quick tip when formatting dates try using the reverse and see what comes out:
Groovy uses SimpleDateFormat under the hood but that’s not that important since most date libraries use the same format conventions.