Jackson E Jackson E - 21 days ago 6
Java Question

Please help me fix my attempt to put the current time into a long

public void Clik(View view){

Calendar c = Calendar.getInstance();
long seconds = c.get(Calendar.SECOND);
TextView calenderTest = (TextView) findViewById(R.id.textView);
String myTime = (String) String.valueOf(calenderTest);
calenderTest.setText(myTime);

}


This app uses a button to get the current time, puts it into a long, and displays it. However I am receiving an output I was not expecting.

Error Received

Answer

Did you mean to use? :)

long seconds = c.get(Calendar.SECOND);
TextView calenderTest = (TextView) findViewById(R.id.textView);
String myTime = (String) String.valueOf(seconds);
calenderTest.setText(myTime);
Comments