How can I get current date in Android?

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

    Date c = Calendar.getInstance().getTime();
    System.out.println("Current time => " + c);
    
    SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
    String formattedDate = df.format(c);
    

    This one is the best answer...

提交回复
热议问题