package java_time; import java.util.Calendar; import java.util.Date; /** * @web http://java-buddy.blogspot.com/ */ public class Java_Time { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); Date calendarDate = calendar.getTime(); System.out.println("Now: " + calendarDate); Calendar cal_Tomorrow = Calendar.getInstance(); cal_Tomorrow.add(Calendar.DATE, 1); Date date_Tomorrow = cal_Tomorrow.getTime(); System.out.println("Tomorrow: " + date_Tomorrow); Calendar cal_Yesterday = Calendar.getInstance(); cal_Yesterday.add(Calendar.DATE, -1); Date date_Yesterday = cal_Yesterday.getTime(); System.out.println("Yesterday: " + date_Yesterday); } }
Saturday, September 28, 2013
Add Date to Calendar
Example to add/minus one Day in Calendar, to get tomorrow and yesterday.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment