Java Calendar MINUTE

Syntax

Calendar.MINUTE has the following syntax.

public static final int MINUTE

Example

In the following code shows how to use Calendar.MINUTE field.


import java.util.Calendar;
/*from  ww w  .  java 2 s .  com*/
public class Main {
  public static void main(String[] args) {
    Calendar now = Calendar.getInstance();
    // add seconds to current date
    now.add(Calendar.SECOND, 500);
    System.out.println("adding 500 seconds : ");
    System.out.println(now.get(Calendar.MINUTE) + ":"
        + now.get(Calendar.SECOND));

    // adding minus value
    now = Calendar.getInstance();
    now.add(Calendar.SECOND, -500);
    System.out.println("adding -500 seconds: ");
    System.out.println(now.get(Calendar.MINUTE) + ":"
        + now.get(Calendar.SECOND));
  }
}

The output: