Home>

Get system time

public class mainactivity extends appcompatactivity {
  @override
  protected void oncreate (bundle savedinstancestate) {
    super.oncreate (savedinstancestate);
    //Create a linear layout manager
    linearlayout layout=new linearlayout (this);
    //Display changed layout
    super.setcontentview (layout);
    layout.setorientation (linearlayout.vertical);
 //Create textview
    final textview show=new textview (this);
 //create button
    button bn=new button (this);
    bn.settext (r.string.ok);
    bn.setlayoutparams (new viewgroup.layoutparams (
        viewgroup.layoutparams.wrap_content,        viewgroup.layoutparams.match_parent));
 //Add textview
    layout.addview (show);
 //add button
    layout.addview (bn);
 //Set a listen event
    bn.setonclicklistener (new view.onclicklistener () {
      @override
      public void onclick (view v) {
        show.settext ("hello, android," + new java.util.date ());
      }
    });
  }
}

Get time

show.settext ("hello, android," + new java.util.date ());

PS:Here are a few more online tools for date and time calculation for your reference:

  • Previous Vue infinite update loop problem solving
  • Next vue implements custom component functions for password show and hide buttons