Android get current date and show it in TextView

前端 未结 10 2147
清歌不尽
清歌不尽 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:44

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
    String currentDateandTime = sdf.format(new Date());
    tv.setText(currentDateandTime);
    

    this is the way how i do it

提交回复
热议问题