2012-07-29 103 views

回答

4

您可以使用CalendarSimpleDateFormat

SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss"); 
Calendar c = Calendar.getInstance(); 
c.setTime(time.parse("18:00:00")); 
c.add(Calendar.HOUR,2); 
System.out.println("New time: "+time.format(c.getTime())); 

輸出將是:

New time: 20:00:00