Hello it happens that I had problem to obtain the records of the date field of a sqlite table, now I have corrected my code to obtain dates like this:
do
{
inicio=new Entidades.TablaInicio(inicio);
inicio.setId(cursor.getInt(cursor.getColumnIndex(_inicio_Utilidades.id)));
inicio.setNombre(cursor.getString(cursor.getColumnIndex(_inicio_Utilidades.Nombre)));
/*------- Fecha -----------*/
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
inicio.setFecha(sdf.parse(cursor.getString(cursor.getColumnIndex(_inicio_Utilidades.Fecha))));
} catch (ParseException e) {
//Error formato no adecuado.
}
listinicio.add(inicio);
}
The problem is that he throws me this error
ATAL EXCEPTION: main Process: com.example.home.sb, PID: 9936 java.lang.NullPointerException at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1009) at java.text.DateFormat.parse
right on this line
inicio.setFecha(sdf.parse(cursor.getString(cursor.getColumnIndex(_inicio_Utilidades.Fecha))));
Thanks for reading. I do this in a fragment.