How to generate date for next 14 days in java? -


public class datefornext14days {     public static void main(string[] args) {         final calendar c = calendar.getinstance();         int day=c.get(calendar.day_of_month);         (int = 1;  i<=14; i++) {             system.out.println(day);             c.add(c.get(calendar.day_of_month), 1);          }     } } 

while executing code got following error:-

exception in thread "main" java.lang.illegalargumentexception @ java.util.gregoriancalendar.add(unknown source) @ todaydate.main(todaydate.java:28)

i wanted output - start current day , iterate next 14 days.

remove c.get(. first parameter of add constant unit

c.add(calendar.day_of_month, 1); 

for more informations see javadoc.

and output day in following way:

system.out.println(c.get(calendar.day_of_month)); 

so code must like:

public static void main(string[] args) {     final calendar c = calendar.getinstance();      (int = 1; <= 14; i++) {         system.out.println(c.get(calendar.day_of_month));         c.add(calendar.day_of_month, 1);     }  } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -