首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

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

2012-12-22 
小例子--当前时间加三天时间减一秒public static void main(String[] args) {?? SimpleDateFormat simpleD

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

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 写道是这个啊 !
你以为呢?其实很简单。

热点排行