列印輸出昨天的目前時間
package ForeverLover;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class DateSystem {
/**
* @author ForeverLover
*/
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
System.out.println(sdf.format(cal.getTime()));
}
}
轉載于:https://www.cnblogs.com/ForeverLover/p/4667854.html