抱歉,我是 Java 的新手,我可以知道如何在这里添加额外的时间吗?
SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String currTimestamp = timestampFormat.format(new Date());
System.err.println("currTimestamp=="+currTimestamp); // 2014/10/17 14:31:33
您可以使用 Calender为此。
Calendar calendar=Calendar.getInstance(); // current time
System.out.println(calendar.getTime());
calendar.add(Calendar.MINUTE,3); // add 3 minutes to current time
System.out.println(calendar.getTime());
输出:
Fri Oct 17 12:17:13 IST 2014
Fri Oct 17 12:20:13 IST 2014