我想在我目前的约会中添加一天。我不知道该怎么做。我的身体请帮助我。 [英] I would like to add one day in my current date.i don't know how to do it.some body please help me.

查看:65
本文介绍了我想在我目前的约会中添加一天。我不知道该怎么做。我的身体请帮助我。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

Here is my code

public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/dd/MM");
        for (int i = 0; i <= 100; i++) {

            Date day = new Date();
            strDate = sdf.format(new Date(day.getTime() + TimeUnit.DAYS.toMillis(1)));
        }
        return inflater.inflate(R.layout.tab1, container, false);
    }
    @Override
    public void onStart() {
        super.onStart();

        TextView textView2 =  getView().findViewById(R.id.textView);
        textView2.setText(strDate);
    }

}





我尝试过:



我尝试了日历方法,还尝试了dateUtill方法。



What I have tried:

I tried calendar method and also tried dateUtill methods.

推荐答案

我得到了答案伙伴。这就是它。

I got answer buddy .Here is it.
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

        //Date day = new Date();
        //strDate=sdf.format(new Date());
        try {
            Date myDate = sdf.parse("14/07/2017");
            Calendar c = Calendar.getInstance();
            c.setTime(myDate);
            c.set(Calendar.DAY_OF_YEAR, c.get(Calendar.DAY_OF_YEAR) + 1);
            Date newDate = c.getTime();
            strDate = sdf.format(newDate);//01/21/2015
        } catch (ParseException e) {
            e.printStackTrace();
            //handle exception
        }
          // number of days to add, can also use Calendar.DAY_OF_MONTH in place of Calendar.DATE
        return inflater.inflate(R.layout.tab2,container,false);
    }
    @Override
    public void onStart() {
        super.onStart();


        TextView textView2 =  getView().findViewById(R.id.textView2);
        textView2.setText(strDate);
    }
}


这篇关于我想在我目前的约会中添加一天。我不知道该怎么做。我的身体请帮助我。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆