如何在android中从当天获取当前日期和第7天?我想以图像给出的以下格式显示日期

kal*_*pea 4 android date android-calendar

在给定的图像中,第一个日期是带有月和日的当前日期。另一个日期是从当前日期算起的第 7 天。

在此处输入图片说明

我尝试使用以下代码::

 Calendar cal = Calendar.getInstance();
            cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
            SimpleDateFormat sdf = new SimpleDateFormat("EEEE dd.MM.yyyy");

            for (int i = 0; i < 7; i++) {
                Log.i("dateTag", sdf.format(cal.getTime()));
                cal.add(Calendar.DAY_OF_WEEK, 1);
            }
        tvDate1=(TextView) findViewById(R.id.calender_view1);
        tvDate1.setText("" + DateFormat.format("dd/MM/yyyy", System.currentTimeMillis()));


tvDate2=(TextView) findViewById(R.id.calender_view2);
        tvDate2.setText("here want to print 7thday");
Run Code Online (Sandbox Code Playgroud)

Nas*_*Nas 6

SimpleDateFormat dateFormat= new SimpleDateFormat("EEEE dd.MM.yyyy");
Calendar currentCal = Calendar.getInstance();
String currentdate=dateFormat.format(currentCal.getTime());
currentCal.add(Calendar.DATE, 7); 
String toDate=dateFormat.format(currentCal.getTime());
Run Code Online (Sandbox Code Playgroud)