获取昨天一整天时间

Calendar c1 = new GregorianCalendar();
c1.set(Calendar.HOUR_OF_DAY, 0);
c1.set(Calendar.MINUTE, 0);
c1.set(Calendar.SECOND, 0);
c1.add(Calendar.DAY_OF_MONTH,-1);
System.out.println(c1.getTime());
Calendar c2 = new GregorianCalendar();
c2.set(Calendar.HOUR_OF_DAY, 23);
c2.set(Calendar.MINUTE, 59);
c2.set(Calendar.SECOND, 59);
c2.add(Calendar.DAY_OF_MONTH,-1);
System.out.println(c2.getTime());

上一篇:java 获取两时间相差月份


下一篇:在聊Java中的equals方法