History log of /libcore/luni/src/test/java/libcore/java/util/GregorianCalendarTest.java
Revision Date Author Comments
b49c7c3f6a74d80580682b53457438a9e95f961d 10-Feb-2017 Joachim Sauer <jsauer@google.com> Add tests for GregorianCalendar.

Add tests to GregorianCalendar.from(ZonedDateTime) and
GregorianCalendar.toZonedDateTime().

Bug: 28832222
Test: vogar libcore.java.util.GregorianCalendarTest
Change-Id: I823e75e17e0110cb5d92c1de40e0470899c99765
ebffddd8bf06a0d9c862e222972544b11788aa00 09-Feb-2017 Tobias Thierer <tobiast@google.com> Tests for Calendar APIs from OpenJDK8u60

This covers:

- GregorianCalendar.{from,to}ZonedDateTime()
- Calendar.toInstant()
- Calendar.getAvailableCalendarTypes()

Notes:
- The supported calendar types may change in a follow-up CL
(bug 35138741). Currently, only "gregory" is listed even
though Calendar.Builder.build() still attempts to use
"buddhist" (this inconsistency is a bug).
- Calendar.Builder is not covered by these tests

Test: CalendarTest, GregorianCalendarTest
Bug: 34923731
Bug: 29935305

Change-Id: Icfa87f465941e63f11f4ef6c35f82cdbcfd313fb
a4750c7d39fb853458c8deb1d0d7da780b29b15a 15-Apr-2016 Neil Fuller <nfuller@google.com> Explicitly set locale to en_US for tests that require it

Previously these tests would use the device setting. The follow tests
broke if the device was set to en_UK:

libcore.java.text.SimpleDateFormatTest#testTimeZoneNotChangedByParse
org.apache.harmony.tests.java.util.GregorianCalendarTest#test_getLeastMaximumI
libcore.java.util.GregorianCalendarTest#test_getWeeksInWeekYear

The GregorianCalendar tests broke because the locale influences the
"start of week".
The SimpleDateFormat test broke because HST is not an ICU translation for
en_UK but is for en_US.

Bug: 28212178
(cherry picked from commit 3819290afba2199d4ddf5da88e5b3717b59863f6)

Change-Id: I15f6e0f0133a876b0d4173dacef8fad7506f52ab
3819290afba2199d4ddf5da88e5b3717b59863f6 15-Apr-2016 Neil Fuller <nfuller@google.com> Explicitly set locale to en_US for tests that require it

Previously these tests would use the device setting. The follow tests
broke if the device was set to en_UK:

libcore.java.text.SimpleDateFormatTest#testTimeZoneNotChangedByParse
org.apache.harmony.tests.java.util.GregorianCalendarTest#test_getLeastMaximumI
libcore.java.util.GregorianCalendarTest#test_getWeeksInWeekYear

The GregorianCalendar tests broke because the locale influences the
"start of week".
The SimpleDateFormat test broke because HST is not an ICU translation for
en_UK but is for en_US.

Bug: 28212178
Change-Id: Id4c9ca48dcc821e8f7c6af22d7e8a9fbce57d62c
869ce9a33446e07f665bd5cdf4b75a73ad314d39 26-Mar-2016 Shubham Ajmera <shubhamajmera@google.com> Add unit tests for java.util.Calendar

and GregorianCalendar

Tests added for:
Calendar.getWeekYear()
Calendar.getWeeksInWeekYear()
Calendar.isWeekDateSupported()
Calendar.setWeekDate(int, int, int)
GregorianCalendar.getWeekYear()
GregorianCalendar.getWeeksInWeekYear()
GregorianCalendar.isWeekDateSupported()
GregorianCalendar.setWeekDate(int, int, int)

Bug: 27330986
(cherry-picked from commit 10a1d6caad617432420db593960829e47b38f761)
Change-Id: I24faf062ec966c097ba84a09292654d1e178e9a4
10a1d6caad617432420db593960829e47b38f761 26-Mar-2016 Shubham Ajmera <shubhamajmera@google.com> Add unit tests for java.util.Calendar

and GregorianCalendar

Tests added for:
Calendar.getWeekYear()
Calendar.getWeeksInWeekYear()
Calendar.isWeekDateSupported()
Calendar.setWeekDate(int, int, int)
GregorianCalendar.getWeekYear()
GregorianCalendar.getWeeksInWeekYear()
GregorianCalendar.isWeekDateSupported()
GregorianCalendar.setWeekDate(int, int, int)

Bug: 27330986
Change-Id: I24faf062ec966c097ba84a09292654d1e178e9a4
90a3721dc9454a67e1c64409782d277424d38fc3 14-Jan-2016 Paul Duffin <paulduffin@google.com> Fix setting a calendar to a time during transition into DST

The transition into Daylight Savings Time (DST), i.e. spring
forward, results in a period of time (equal to the DST offset)
during which the wall clock time is incorrect. Basically, the
GregorianCalendar does not handle that situation properly and
calculates the wrong UTC time (in millis since 1st January
1970).

The reason this exists in Enso is because in OpenJDK the
handling of that situation is not performed directly in
GregorianCalendar computeTime() but instead in a special method
in sun.util.calendar.ZoneInfo. That means OpenJDK has similar
behavior to enso when a different TimeZone implementation, such
as SimpleTimeZone is used. That special code was removed so it
fell back to the code that is used for SimpleTimeZone which is
broken.

In pre-enso GregorianCalendar has a special method getOffset()
that is called for all instances of TimeZone that handles the
case so unlike OpenJDK it does work for SimpleTimeZone.

The solution is to add some code into GregorianCalendar that
handles the transition into DST specially. That means it will
work the same as pre-enso, not OpenJDK for SimpleTimeZone. As
it is complex I have refactored the code a bit more than
necessary in order to improve the structure and add some extra
documentation. I also added extra tests, some of which do not
work in OpenJDK.

Bug: 25897679
Change-Id: I06d0c81e8da20ec00267ed8ba24b26a8a2c163ed
dda702b5a424ec84623e1a1e285c3ba0d515c131 17-Dec-2015 Paul Duffin <paulduffin@google.com> Fix, expand and move test for GregorianCalendar change date

The part of the test_getLeastMaximumI test that is broken is
checking a fix that was added in
https://issues.apache.org/jira/browse/HARMONY-2947. The fix
aimed to make the method obey its contract and take into
consideration the current values of the getFirstDayOfWeek,
getMinimalDaysInFirstWeek, getGregorianChange and
getTimeZone methods but it didn't.

The test broken because OpenJDK considered TimeZone, and the
test used the default time zone so it varied from run to run
which explains why it worked in some cases but not in others.

There are a number of other fields (apart from WEEK_OF_YEAR that
are affected by the transition between Gregorian and Julian
calendars so the part of the test that was broken was moved to
libcore.java.util.GregorianCalendarTest, fixed to work properly
by setting the TimeZone explicitly and expanded to test the
other fields too.

Bug: 25998114
Change-Id: I4fb6ed6143c682fce6cd2029d09bd59b17b3541d
3adfa669da17e644700961647574b2cb7a309139 17-Dec-2015 Paul Duffin <paulduffin@google.com> Fix test to match behavior of OpenJDK and RI

Bug: 26023857
Change-Id: Ib0632d9b04e54d38dc0e7bff18b6772ea605fc79
4eb6dd5362871b00084b2fe0cfb4f4b87f052d4c 20-Nov-2013 Narayan Kamath <narayan@google.com> Document some surprising GregorianCalendar behavior.

bug: https://code.google.com/p/android/issues/detail?id=61993

Change-Id: I1725808187f23ddaa6ab1d14348c3b7702a5f833