Android get current date and show it in TextView

前端 未结 10 2113
清歌不尽
清歌不尽 2021-02-14 09:23

I do not know what is wrong with code below -

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layo         


        
10条回答
  •  迷失自我
    2021-02-14 09:51

    note*:

    import java.text.DateFormat;
    import java.util.Date;
    
    // Donot import "import java.sql.Date;"
    
    TextView tv = (TextView) findViewById(R.id.textView1);
    String ct = DateFormat.getDateInstance().format(new Date());
    tv.setText(ct);
    

提交回复
热议问题