I have a method to return the current date by using the Calendar like this:
Calendar calendar = Calendar.getInstance();
dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
month = calendar.get(Calendar.MONTH);
year = calendar.get(Calendar.YEAR);
On the other hand, I have a DatePickerDialog which I need to update the previous values.
private void launchDatePicker() {
final Calendar calendar = Calendar.getInstance();
int nuevoDia = calendar.get(Calendar.DAY_OF_MONTH);
int nuevoDiaSemana = calendar.get(Calendar.DAY_OF_WEEK);
int nuevoMes = calendar.get(Calendar.MONTH);
int nuevoAño = calendar.get(Calendar.YEAR);
DatePickerDialog datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int nuevoAño, int nuevoMes, int nuevoDia) {
//int nuevoDiaSemana = calendar.get(Calendar.DAY_OF_WEEK);
dayOfMonth = nuevoDia;
month = nuevoMes;
year = nuevoAño;
fechaActual(dayOfWeek, dayOfMonth,month);
ajustarFormatoFecha();
readFromDichos();
faseLunar();
}
}
,nuevoDia,nuevoMes,nuevoAño);
datePickerDialog.show();
}
The problem is that this DatePicker always starts in year = 1900. How can I start it in the current date?
How can I get DayOfTheWeek by using the DatePickerDialog?