[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/27343] New: Calling java.util.Calendar#setTimeZone() does
From: |
kiyun dot roe at active-endpoints dot com |
Subject: |
[Bug classpath/27343] New: Calling java.util.Calendar#setTimeZone() does not force recalculation of calendar fields |
Date: |
27 Apr 2006 22:31:15 -0000 |
The Calendar implementation does not recalculate its fields when the time zone
changes. This leads to behavior where the time zone changes, but the hour of
the day doesn't. Here is a little test case that demonstrates the problem.
public class CalendarSetTimeZoneTest extends TestCase
{
public void testCalendarSetTimeZone()
{
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.setTimeZone(java.util.TimeZone.getTimeZone("GMT+0"));
cal.setTime(new java.util.Date());
int hour1 = cal.get(java.util.Calendar.HOUR_OF_DAY);
cal.setTimeZone(java.util.TimeZone.getTimeZone("GMT-5"));
int hour2 = cal.get(java.util.Calendar.HOUR_OF_DAY);
int delta = (hour1 - hour2 + 24) % 24;
assertEquals(delta, 5);
}
}
--
Summary: Calling java.util.Calendar#setTimeZone() does not force
recalculation of calendar fields
Product: classpath
Version: 0.90
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: classpath
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kiyun dot roe at active-endpoints dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27343
- [Bug classpath/27343] New: Calling java.util.Calendar#setTimeZone() does not force recalculation of calendar fields,
kiyun dot roe at active-endpoints dot com <=