小编kal*_*pea的帖子

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

在给定的图像中,第一个日期是带有月和日的当前日期。另一个日期是从当前日期算起的第 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)

android date android-calendar

4
推荐指数
1
解决办法
4056
查看次数

标签 统计

android ×1

android-calendar ×1

date ×1