How can I get current date in Android?

前端 未结 26 2178
[愿得一人]
[愿得一人] 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:21

    You can use following code to get a date in the format you want.

    String date = String.valueOf(android.text.format.DateFormat.format("dd-MM-yyyy", new java.util.Date()));
    

提交回复
热议问题