I made a class called DataHoraAtual containing this data:
package com.projeto.projetov1.model;
import java.text.SimpleDateFormat;
public class DataHoraAtual {
long date = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
String dateString = sdf.format(date);
}
And in my main class, when the event is created it has this code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//aplica data hora atual do sistema no app
txtDataHoraOcorrencia = (EditText)
findViewById(R.id.txtDataHoraOcorrencia);
DataHoraAtual dataHoraAtual = new DataHoraAtual();
txtDataHoraOcorrencia.setText(dataHoraAtual.toString());
}
Doing so the date and time is not displayed, but the following appears:
with.project.projectv1.model.database=4f3b05b
But if I do so, without calling the class the date and time appears:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//aplica data hora atual do sistema no app
txtDataHoraOcorrencia = (EditText) findViewById(R.id.txtDataHoraOcorrencia);
long date = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
String dateString = sdf.format(date);
txtDataHoraOcorrencia.setText(dataHoraAtual.toString());
}
What am I doing wrong?
Doing the procedure suggested by Valdeir presented the following: