I want to convert the date format to string, but the string output is not coming
DateFormat currentDate = new SimpleDateFormat("dd MM yyyy ");
String currDateString = String.valueOf(currentDate);
System.out.println(currDateString);
I want to convert the date format to string, but the string output is not coming
DateFormat currentDate = new SimpleDateFormat("dd MM yyyy ");
String currDateString = String.valueOf(currentDate);
System.out.println(currDateString);
To format current date you need to create a instance of Date
which represents current date and then format it using SimpleDateFormat
to string.
DateFormat dateFormat = new SimpleDateFormat("dd MM yyyy");
String currDateString = dateFormat.format(new Date());
System.out.println(currDateString);