dd/mm/yyyy vs dd/MM/yyyy?
It's because mm
is for minutes, not months. More in the documentation.
mm
represents minutes, so when you use mm
, it will print minutes instead of month.
While MM
represents months.
Read more about Time Patterns
In C# and VB.NET, it's a case sensitive especially to format the Month or Minutes. Because initial character of both the words is same.
The following detail may help you in formatting the date & time.
1. d/D: day without 0 prefix on single digit.
2. dd/DD: day with 0 prefix if single digit.
3. M: Month without 0 prefix on single digit.
4. MM: Month with 0 prefix if single digit.
5. yy/YY: Last two digit of year.
6. yyyy/YYYY: represents full year.
7. HH: 24 hour based hour. ie. 13:00. **H** will display hour without prefix 0 if single digit
8. hh: 12 hour based hour. ie. 01:00. **h** will display hour without prefix 0 if single digit
9. m: minute without 0 prefix on single digit.
10.mm: minute with 0 prefix if single digit.
11.s: second without 0 prefix on single digit.
12.ss: second with 0 prefix if single digit.
13.tt: represent the AM or PM
Yes it is because mm
represents minutes
Date date=new Date();
System.out.println(date);
System.out.println("Date: "+new SimpleDateFormat("dd/MM/yyyy").format(date));
System.out.println("Date: "+new SimpleDateFormat("dd/mm/yyyy").format(date));
if you observed the output you will find when we print date object, there is value of minutes, month, etc and in 2nd line and 3rd line same minute is printed corresponding to mm and month value is printed corresponding to MM
Thu Feb 20 14:33:00 IST 2020
20/02/2020
20/33/2020