打印输出昨天的当前时间
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())); } }
时间: 2024-10-17 09:59:25