I'm having problem when I try to reset the Calendar because it doesn't recover the original date. What am I doing wrong ?
public static void main(String[] args) {
Calendar from = Calendar.getInstance();
int contador = 0;
while (contador < 30) {
Calendar cal = from;
for (int i = 0; i < 3; i++) {
cal.add(Calendar.DAY_OF_YEAR, +1);
System.out.println("Dia: " + String.valueOf(cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH)));
}
contador++;
}
}
That is the result:
Dia: 2017/6/21
Dia: 2017/6/22
Dia: 2017/6/23
Dia: 2017/6/24
Dia: 2017/6/25
Dia: 2017/6/26
Dia: 2017/6/27
Dia: 2017/6/28
Dia: 2017/6/29
Dia: 2017/6/30
......