Java Calendar add subtract weeks

Description

Java Calendar add subtract weeks

import java.util.Calendar;

public class Main {

  public static void main(String[] args) {
    Calendar now = Calendar.getInstance();

    System.out.println("Current date : " + now.getTime());

    now.add(Calendar.WEEK_OF_YEAR, 1);

    System.out.println(now.getTime());

    now = Calendar.getInstance();
    now.add(Calendar.WEEK_OF_YEAR, -10);

    System.out.println( now.getTime());

  }//from  ww w .  j  a v  a2s  .  c  o  m
}



PreviousNext

Related