My server was setted with 'America/Sao_Paulo' TimeZone, and this year in october 21th the daylight saving started.
Why if I do this
public static void main(String[] args){
Calendar d1 = new GregorianCalendar(2012, 9, 19, 0, 0, 0);
Calendar d2 = new GregorianCalendar(2012, 9, 22, 0, 0, 0);
while(d1.compareTo(d2) <= 0){
System.out.println("\nBEFORE: " + d1.getTime());
d1.add(Calendar.DAY_OF_MONTH, 1);
System.out.println("AFTER: " + d1.getTime());
}
}
I have this output
BEFORE: Fri Oct 19 00:00:00 BRT 2012
AFTER: Sat Oct 20 00:00:00 BRT 2012
BEFORE: Sat Oct 20 00:00:00 BRT 2012
AFTER: Sun Oct 21 01:00:00 BRST 2012
BEFORE: Sun Oct 21 01:00:00 BRST 2012
AFTER: Mon Oct 22 01:00:00 BRST 2012
when I do this d1.add(Calendar.DAY_OF_MONTH, 1) just the day should be increased not the hour too, right? How can I avoid this, and maintain the original hour, I do not want to use GMT-3, I need to now when is DST.
thanksss