import java.util.Calendar;
/** from 时 代 J a v a - N o w J a v a . c o m**/
public class Main {
public static void main(String[] args) {
Calendar now = Calendar.getInstance();
System.out.println("Current time : " + now.get(Calendar.HOUR_OF_DAY)
+ ":"
+ now.get(Calendar.MINUTE)
+ ":"
+ now.get(Calendar.SECOND));
now.add(Calendar.SECOND,100);
/**
来 自 时 代 J a v a 公 众 号
**/
System.out.println("New time after adding 100 seconds : "
+ now.get(Calendar.HOUR_OF_DAY)
+ ":"
+ now.get(Calendar.MINUTE)
+ ":"
+ now.get(Calendar.SECOND));
//subtract seconds from current time using Calendar.add method
now = Calendar.getInstance();
now.add(Calendar.SECOND, -50);
/**代码未完, 请加载全部代码(NowJava.com).**/