X
Xandau
on the beginning i have to say that i use SDK 1.3.1_11
public void m() {
Integer scanInterval = new Integer(581);
try {
Date d;
GregorianCalendar gc = new GregorianCalendar();
GregorianCalendar gc2 = new GregorianCalendar();
System.out.println("GC = "+ gc.getTime().toString());
gc.set(gc.HOUR_OF_DAY, gc.get(gc.HOUR_OF_DAY) +
scanInterval.intValue());
System.out.println("GC = "+ gc.getTime().toString());
gc2.add(GregorianCalendar.HOUR_OF_DAY, scanInterval.intValue());
System.out.println("GC2 = "+ gc2.getTime().toString());
System.out.println("XXX "+ gc.get(gc.HOUR_OF_DAY));
} catch (Exception ex) {
ex.printStackTrace();
}
}
and on standard output we can see:
GC = Tue Jun 22 15:03:42 CEST 2004
GC = Fri Jul 16 20:03:42 CEST 2004
GC2 = Fri Jul 16 20:03:42 CEST 2004
XXX 20
- so the results are excactrly the same as we have expected ...
but if we change a value of "scanInterval" to higher like 585 or more...
public void m() {
Integer scanInterval = new Integer(590);
try {
Date d;
GregorianCalendar gc = new GregorianCalendar();
GregorianCalendar gc2 = new GregorianCalendar();
System.out.println("GC = "+ gc.getTime().toString());
gc.set(gc.HOUR_OF_DAY, gc.get(gc.HOUR_OF_DAY)
+scanInterval.intValue());
System.out.println("GC = "+ gc.getTime().toString());
gc2.add(GregorianCalendar.HOUR_OF_DAY, scanInterval.intValue());
System.out.println("GC2 = "+ gc2.getTime().toString());
System.out.println("XXX "+ gc.get(gc.HOUR_OF_DAY));
} catch (Exception ex) {
ex.printStackTrace();
}
}
the results are unbelivible :
GC = Tue Jun 22 15:07:37 CEST 2004
GC = Fri May 28 12:04:50 CEST 2004
^^^^^^^^^^^^^^^^^^^^^^^^^^
GC2 = Sat Jul 17 05:07:37 CEST 2004
XXX 12
i am wondering why 580 hours is counted corrected but 584 is counted
wrong...
regards,
Adam
public void m() {
Integer scanInterval = new Integer(581);
try {
Date d;
GregorianCalendar gc = new GregorianCalendar();
GregorianCalendar gc2 = new GregorianCalendar();
System.out.println("GC = "+ gc.getTime().toString());
gc.set(gc.HOUR_OF_DAY, gc.get(gc.HOUR_OF_DAY) +
scanInterval.intValue());
System.out.println("GC = "+ gc.getTime().toString());
gc2.add(GregorianCalendar.HOUR_OF_DAY, scanInterval.intValue());
System.out.println("GC2 = "+ gc2.getTime().toString());
System.out.println("XXX "+ gc.get(gc.HOUR_OF_DAY));
} catch (Exception ex) {
ex.printStackTrace();
}
}
and on standard output we can see:
GC = Tue Jun 22 15:03:42 CEST 2004
GC = Fri Jul 16 20:03:42 CEST 2004
GC2 = Fri Jul 16 20:03:42 CEST 2004
XXX 20
- so the results are excactrly the same as we have expected ...
but if we change a value of "scanInterval" to higher like 585 or more...
public void m() {
Integer scanInterval = new Integer(590);
try {
Date d;
GregorianCalendar gc = new GregorianCalendar();
GregorianCalendar gc2 = new GregorianCalendar();
System.out.println("GC = "+ gc.getTime().toString());
gc.set(gc.HOUR_OF_DAY, gc.get(gc.HOUR_OF_DAY)
+scanInterval.intValue());
System.out.println("GC = "+ gc.getTime().toString());
gc2.add(GregorianCalendar.HOUR_OF_DAY, scanInterval.intValue());
System.out.println("GC2 = "+ gc2.getTime().toString());
System.out.println("XXX "+ gc.get(gc.HOUR_OF_DAY));
} catch (Exception ex) {
ex.printStackTrace();
}
}
the results are unbelivible :
GC = Tue Jun 22 15:07:37 CEST 2004
GC = Fri May 28 12:04:50 CEST 2004
^^^^^^^^^^^^^^^^^^^^^^^^^^
GC2 = Sat Jul 17 05:07:37 CEST 2004
XXX 12
i am wondering why 580 hours is counted corrected but 584 is counted
wrong...
regards,
Adam