public class Demo {
public static void main(String[] args) {
Date date = new Date()//当前时间
int addDay = 2//加两天
date.setDate(date.getDate()+addDay)
System.out.println(date.toLocaleString())
}
}
String startdate=UIDBComboBox1.getValue()
Date date = (new SimpleDateFormat("yyyy-MM-dd")).parse(startdate)
Calendar cal = Calendar.getInstance()
cal.setTime(date)
cal.add(Calendar.DATE,1)
date =cal.getTime()
startdate = (new SimpleDateFormat("yyyy-MM-dd")).format(date);
举例:
import java.text.Format
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
public class $ {
public static void main(String[] args) {
Format f = new SimpleDateFormat("yyyy-MM-dd")
Date today = new Date()
System.out.println("今天是:" + f.format(today))
Calendar c = Calendar.getInstance()
c.setTime(today)
c.add(Calendar.DAY_OF_MONTH, 1)// 今天+1天
Date tomorrow = c.getTime()
System.out.println("明天是:" + f.format(tomorrow))
}
}
结果:
今天是:2013-10-09
明天是:2013-10-10
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)