How to get the date one year from now with add weeks using Calendar in Java

1 Answer

0 votes
package javaapplication1;

import java.util.Calendar;

public class JavaApplication1 {

    public static void main(String[] args) {

        Calendar now = Calendar.getInstance();
        
        System.out.println("Today: " + (now.get(Calendar.MONTH) + 1)  + "-"
                           + now.get(Calendar.DATE)
                           + "-"
                           + now.get(Calendar.YEAR));
        
        now.add(Calendar.WEEK_OF_MONTH, 52);
        
        System.out.println("Today + 52 Weeks: " + (now.get(Calendar.MONTH) + 1)  + "-"
                           + now.get(Calendar.DATE)
                           + "-"
                           + now.get(Calendar.YEAR));
    }
}

/*

run:

Today: 10-19-2016
Today + 52 Weeks: 10-18-2017

*/

 



answered Oct 19, 2016 by avibootz

Related questions

1 answer 183 views
1 answer 209 views
1 answer 191 views
1 answer 246 views
1 answer 232 views
1 answer 257 views
1 answer 219 views
...