让我们说今天是随机的一天,我想找到下周二的日期。目前我只能找到本周二的日期......
cal.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
我怎么能在星期二下午离开并忘记上周二?
答案 0 :(得分:1)
怎么样......
cal.set( Calendar.DAY_OF_WEEK, Calendar.TUESDAY );
cal.add( Calendar.DATE, 7 );
通常,这些问题导致一群人正确地大喊大叫#34; JODA!"
[bwoogie编辑]我的最终代码:
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
if(c.getTimeInMillis() < System.currentTimeMillis()) {
c.add(Calendar.DATE, 7);
}
答案 1 :(得分:0)
试试这个
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
calendar.add(Calendar.DAY_OF_WEEK, 7);
SimpleDateFormat f = new SimpleDateFormat("MM/d/yyyy");
Log.d("Next", f.format(cal.getTime()));