How can I get current date in Android?

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

    I wrote calendar app using CalendarView and it's my code:

    CalendarView cal = (CalendarView) findViewById(R.id.calendar);
    cal.setDate(new Date().getTime());
    

    'calendar' field is my CalendarView. Imports:

    import android.widget.CalendarView;
    import java.util.Date;
    

    I've got current date without errors.

提交回复
热议问题