Android get current date and show it in TextView

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

    Calendar c = Calendar.getInstance();
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String formattedDate = df.format(c.getTime());
    System.out.println("Currrent Date Time : "+formattedDate);
    

提交回复
热议问题