I have this code, as you can see the name of a worker is registered, but I do not know how to show that time in textView
, because if I do this, tvHora.setText(date);
does not show me anything and the app closes .
private String getDate() {
SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE dd/MM/yyyy hh:mm a", Locale.getDefault());
Date date = new Date();
return dateFormat.format(date);
}
public void guardar(){
String Nombre = text.getText().toString();
SQLite base = new SQLite( this,"SQLite",null,1 );
SQLiteDatabase bd = base.getWritableDatabase();
ContentValues contenedor = new ContentValues();
contenedor.put("NOMBRE", Nombre );
contenedor.put( "FECHA",getDate() );
try {
bd.insertOrThrow("TRABAJADOR",null,contenedor);
Toast.makeText( getApplicationContext(),"Ingresado Correctamente",Toast.LENGTH_SHORT ).show();
}catch (SQLException e){
Toast.makeText( getApplicationContext(),"No Ingresado",Toast.LENGTH_SHORT ).show();
}
bd.close();
}