👉Set Date and Time in various format
private EditText mNoteDate = findViewById(R.id.editTextDate);
String currentDate = new SimpleDateFormat("EEE, dd/MM/yyyy h:mm a",
Locale.getDefault()).format(new Date());
mNoteDate.setText(currentDate);
//Anoter Ways
just one line code to get simple Date format :
SimpleDateFormat.getDateInstance().format(Date())
output : 18-May-2020
SimpleDateFormat.getDateTimeInstance().format(Date())
output : 18-May-2020 11:00:39 AM
SimpleDateFormat.getTimeInstance().format(Date())
output : 11:00:39 AM
0 Comments