Sunday 27 March 2016

How to get today's Date in java in the following pattern dd/MM/yyyy?

I am trying the code



    Date today = new Date();
Date todayWithZeroTime;
{
try {
todayWithZeroTime = formatter.parse(formatter.format(today));

} catch (ParseException e) {
e.printStackTrace();
}
}
String date = todayWithZeroTime.toString();


it is giving output :- Wed Dec 11 00:00:00 IST 2019
where I want 11/12/2019
where 11/12/2019 is today's date

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...