4个回答
展开全部
Calendar c = Calendar.getInstance();//可以对每个时间域单独修改
//c.set(year,month,date);如果你随意输入时间
//Date date = c.getTime();得到date
//如果格式还要求 就用SimpleDateFormat sf=new SimpleDateFormat("YYYY-MM-DD");
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int date = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
System.out.println("当前时间"+year + "/" + month + "/" + date + " " +hour + ":" +minute + ":" + second);
c.set(year, month, date+1);
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
date = c.get(Calendar.DATE);
hour = c.get(Calendar.HOUR_OF_DAY);
minute = c.get(Calendar.MINUTE);
second = c.get(Calendar.SECOND);
System.out.println("当前时间"+year + "/" + month + "/" + date + " " +hour + ":" +minute + ":" + second);
//这是我以前联系着玩用的 你可以看看
//c.set(year,month,date);如果你随意输入时间
//Date date = c.getTime();得到date
//如果格式还要求 就用SimpleDateFormat sf=new SimpleDateFormat("YYYY-MM-DD");
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int date = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
System.out.println("当前时间"+year + "/" + month + "/" + date + " " +hour + ":" +minute + ":" + second);
c.set(year, month, date+1);
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
date = c.get(Calendar.DATE);
hour = c.get(Calendar.HOUR_OF_DAY);
minute = c.get(Calendar.MINUTE);
second = c.get(Calendar.SECOND);
System.out.println("当前时间"+year + "/" + month + "/" + date + " " +hour + ":" +minute + ":" + second);
//这是我以前联系着玩用的 你可以看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用Calendar 天数+1就行了
代码:
public static void main(String args[]){
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
Date date = new Date();// 定义Date
Date date2 = getDate(date);
System.out.println(sdf.format(date2));
}
// 公共方法
public static Date getDate(Date date){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, 1);
Date date1 = new Date(calendar.getTimeInMillis());
return date1;
}
代码:
public static void main(String args[]){
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
Date date = new Date();// 定义Date
Date date2 = getDate(date);
System.out.println(sdf.format(date2));
}
// 公共方法
public static Date getDate(Date date){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, 1);
Date date1 = new Date(calendar.getTimeInMillis());
return date1;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-11-03
展开全部
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, 1);
Date d = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
Date d = cal.getTime();
追问
DAY_OF_YEAR 我要的任意一天的下一天 不是当前时间的下一天
追答
Calendar 可以指定任意一天时间,不指定 默认是当天, 你百度 Calendar 的 用法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询