Android CalendarView: How do I get the date in correct format?

前端 未结 4 864
我在风中等你
我在风中等你 2021-01-20 18:26

The past few days I\'ve been searching for ways to get a \'readable\' date out of my calendarview from android 4.0. I can\'t manage to find a solution or example that suits

4条回答
  •  悲&欢浪女
    2021-01-20 19:10

    long date = calenderView.getDate();
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(date);
    int Year = calendar.get(Calendar.YEAR);
    int Month = calendar.get(Calendar.MONTH);
    int Day = calendar.get(Calendar.DAY_OF_MONTH);
    //customize According to Your requirement
    String finalDate=Year+"/"+Month+"/"+Day;
    

提交回复
热议问题