现在有这个时间格式:2005-11-21 20:21:30 ,现在要加20秒上去,然后输出后还是
2005-11-21 20:31:10这样的时间格式,要怎么弄?
我现在已经得到了如下的格式:Thu Sep 15 19:40:20 CST 2005 ,能不能把这个格式转成上面那养的格式?
2005-11-21 20:31:10这样的时间格式,要怎么弄?
我现在已经得到了如下的格式:Thu Sep 15 19:40:20 CST 2005 ,能不能把这个格式转成上面那养的格式?
import java.text.SimpleDateFormat;public class DateFormat { public static final String FormatType = "yyyy-MM-dd HH:mm:ss.SSS";
SimpleDateFormat sdf2 = new SimpleDateFormat(FormatType);
public String FormatDate(java.util.Date iDate) {
String lsResult = "";
lsResult = sdf2.format(iDate);
return lsResult;
} public java.util.Date Paser(String lsDateTime)
throws Exception {
java.util.Date lcDate = null;
lcDate = sdf2.parse(lsDateTime);
return lcDate;
}
}
Calendar c = Calendar.getInstance();
c.setTime(df.parse("2005-11-21 20:21:30"));
c.add(Calendar.SECOND,20);
System.out.println(df.format(c.getTime()));