日期:2014-05-20 浏览次数:20795 次
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class Test {
public final static String DEFAULTDATEPATTERN2 = "MM-dd-yyyy";
public final static SimpleDateFormat DEFAULTDATEFORMATTER2 = new SimpleDateFormat(DEFAULTDATEPATTERN2);
public static void main(String args[]) {
Calendar calendar = Calendar.getInstance();
// zero out the hours, minutes and seconds
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.add(Calendar.MONTH, 3);
//Thread unsafe
String datestr=DEFAULTDATEFORMATTER2.format(calendar.getTime());
System.out.println(datestr);
Runtime rt = Runtime.getRuntime();
try {
rt.exec("cmd /C date " + datestr);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
proc = Runtime.getRuntime().exec(command);
BufferedReader isInfo = proc.getInputStream();
BufferedReader isError = proc.getErrorStream();