I have date like mm-dd-yyy
in string format and I am trying to convert the same to Date object in java,
Two ways I tried in
- sending the date format as
"mm-dd-yyy"
which is returning the wrong date, it always returns month Jan even though the month in the string is not "01" - sending the date format as
"MM-dd-yyy"
will return the correct date as expected.
But I want to understand why the first approach returning wrong? Can any body tell me the reason.