读书人

小事例-当前时间加三天时间减一秒

发布时间: 2012-12-22 12:05:06 作者: rapoo

小例子--当前时间加三天时间减一秒

public static void main(String[] args) {
?? SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
???? Date currentDate = new Date(System.currentTimeMillis());?
???? Calendar calender = Calendar.getInstance();
??? calender.setTime(currentDate);
??? System.out.println("当天时间:"+currentDate.toLocaleString());
?????calender.add(Calendar.DATE, 3);
?????calender.add(Calendar.SECOND, -1);
?????Date dueTime=null;
???? try {
????? dueTime = simpleDateFormat.parse(simpleDateFormat.format(calender.getTime()).toString());
??????? ?} catch (ParseException e) {
??
????? e.printStackTrace();
???? ?}
??? System.out.println("input into endDate:"+dueTime.toLocaleString());
?????
???
?
?}

1 楼 xiang37 2011-06-01 是这个啊 ! 2 楼 haohao-xuexi02 2011-06-01 xiang37 写道是这个啊 !
你以为呢?其实很简单。

读书人网 >编程

热点推荐