GregorianCalendar: roll(int field, boolean up) : GregorianCalendar « java.util « Java by API






GregorianCalendar: roll(int field, boolean up)

  
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Main {
  public static void main(String[] a) {
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.roll(Calendar.MONTH, false); // Go back a month
    System.out.println(calendar.get(Calendar.MONTH));
  }
}

   
    
  








Related examples in the same category

1.new GregorianCalendar()
2.new GregorianCalendar(int year, int month, int dayOfMonth)
3.new GregorianCalendar(Locale aLocale)
4.new GregorianCalendar(TimeZone zone, Locale aLocale)
5.GregorianCalendar: get(int a)
6.GregorianCalendar: getTime()
7.GregorianCalendar: isLeapYear()
8.GregorianCalendar: set(int field, int value)
9.GregorianCalendar: set(int year, int month, int date)
10.GregorianCalendar: setTime(Date date)