打印昨天的當(dāng)前時(shí)刻
import java.util.Calendar; public class YesterdayCurrent { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1); //根據(jù)日歷的規(guī)則,為給定的日歷字段添加或減去指定的時(shí)間量 System.out.println(cal.getTime()); //返回表示此Calendar時(shí)間值的Date對(duì)象 } }
|