How can I get the computer’s date in Java? I want just year, month, day. Like
2012-07-01
I tried to get Calender
like this
Calendar c = Calendar.getInstance();
c.clear(Calendar.HOUR)
but can't know to deal with it.
First link on google:
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
private String getDateTime() {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
return dateFormat.format(date);
}