How to get the current date correctly?


This question already has an answer here:

  • incorrect conversion of String into date format 3 answers

I tried to get the current date in a specific format, but instead of the month got minutes

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class CurrentDate {

    public static String currentDate() {
    String timeStamp = new SimpleDateFormat("mm/dd/yyyy").format(Calendar.getInstance().getTime());
    return timeStamp;

    public static void main (String [] args) {


Why this code gives minutes ... i tried mon ... ???

You want "MM/dd/yyyy" in the SimpleDateFormat. If you look at the documentation at you'll see that lower case m always means minutes, and capital M is month.