2
I am developing an application and need to pick up the current date only, I used the Date data = new Date();
only it doesn’t work. I tried localdatetime
also more was not, someone has some suggestion?
2
I am developing an application and need to pick up the current date only, I used the Date data = new Date();
only it doesn’t work. I tried localdatetime
also more was not, someone has some suggestion?
10
Tell you what, import SimpleDateFormat
import java.text.SimpleDateFormat;
Create a class instance by passing the date format
SimpleDateFormat formataData = new SimpleDateFormat("dd-MM-yyyy");
Create a class instance 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 on ideone
To get the current date and format it the Calendar
is not necessary
@Isac truth I floated :) Tkx
java.util.Date dataUtil = new java.util.Date(); Date dataSql = new java.sql.Date(dataUtil.getTime());
I got it this way, I take the useful type and convert to sql, in case I needed it in the date type same, without converting
You could set the date format yyyy-MM-dd
which will also work.
Browser other questions tagged java android date
You are not signed in. Login or sign up in order to post.
Doesn’t work because?
– ramaral
Possible duplicate of Pick up show and change Time / Date
– vinibrsl