package test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class TestTime {
public static void main(String[] args) {
String str = "2014-11-24 15:23:20";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
try {
Date myDate = formatter.parse(str);
Calendar c = Calendar.getInstance();
c.setTime(myDate);
//在原時間分鐘加40
c.add(Calendar.MINUTE, 40);
myDate = c.getTime();
//輸出會自動更新時間
System.out.println(formatter.format(myDate));
} catch (ParseException e1) {
e1.printStackTrace();
}
}
}