How can I get current date in Android?

前端 未结 26 2156
[愿得一人]
[愿得一人] 2020-11-27 10:24

I wrote the following code

Date d = new Date();
CharSequence s  = DateFormat.format(\"MMMM d, yyyy \", d.getTime());

But is asking me para

26条回答
  •  心在旅途
    2020-11-27 11:11

    This is nothing to do with android as it is java based so you could use

    private String getDateTime() { 
       DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
       Date date = new Date(); 
       return dateFormat.format(date); 
    }
    

提交回复
热议问题