Java Data Type How to - Add 60 to your age








Question

We would like to know how to add 60 to your age.

Answer

import java.text.SimpleDateFormat;
import java.util.Calendar;
/*from ww w  . j av  a  2s.c om*/
public class Main {

    public static void main(String... args){

        SimpleDateFormat df = new SimpleDateFormat("MM/dd/YYYY");

        Calendar c = Calendar.getInstance();
        System.out.println(df.format(c.getTime()));

        c.add(Calendar.YEAR, 60);
        System.out.println(df.format(c.getTime())); 
    }
}

The code above generates the following result.