I'm developing an application and I need to get the current date only, I used Date data = new Date();
only that it does not work. I tried localdatetime
also more was not, does anyone have any suggestions?
I'm developing an application and I need to get the current date only, I used Date data = new Date();
only that it does not work. I tried localdatetime
also more was not, does anyone have any suggestions?
Do the following, import SimpleDateFormat
import java.text.SimpleDateFormat;
Create an instance of the class, passing the date format
SimpleDateFormat formataData = new SimpleDateFormat("dd-MM-yyyy");
Create an instance of class Date
Date data = new Date();
Format the date
String dataFormatada = formataData.format(data);
Exit
System.out.println("Data formatada " + dataFormatada );
// Data formatada 21-09-2017
See working at ideone