Fix bug in formatting intervals at month boundaries.

In formatting date intervals, we subtract one day from the end time
if it falls on midnight the next day so that both times are in the
same day, thereby avoiding the date appearing in the formatted
interval. We did this by calling endCalendar.roll(Calendar.DAY_OF_MONTH, false).
However, if endCalendar was 1 May 2015 (say), the date rolls over
to 31 May 2015 (this is the documented behaviour of roll).

We now use endCalendar.add(Calendar.DAY_OF_MONTH, -1) which always
subtracts a day so that 1 May 2015 becomes 30 April 2015, this is
the desired behavior.

bug: 20708022

Change-Id: Id222582b26170a91a4ce2f4b5ebef3c15bce7c92
diff --git a/expectations/knownfailures.txt b/expectations/knownfailures.txt
index a3e9197..6470e36 100644
--- a/expectations/knownfailures.txt
+++ b/expectations/knownfailures.txt
@@ -1509,13 +1509,5 @@
     "libcore.java.util.zip.Zip64FileTest#testZip64Support_totalLargerThan4G",
     "libcore.java.util.zip.Zip64FileTest#testZip64Support_hugeEntry"
   ]
-},
-{
-  description: "ICU bug in formatting of dates that span month boundaries",
-  result: EXEC_FAILED,
-  bug: 20708022,
-  names: [
-    "libcore.icu.DateIntervalFormatTest#testEndOfDayOnLastDayOfMonth"
-  ]
 }
 ]
diff --git a/luni/src/main/java/libcore/icu/DateIntervalFormat.java b/luni/src/main/java/libcore/icu/DateIntervalFormat.java
index 509d0a0..7e7ad01 100644
--- a/luni/src/main/java/libcore/icu/DateIntervalFormat.java
+++ b/luni/src/main/java/libcore/icu/DateIntervalFormat.java
@@ -75,7 +75,7 @@
     if (startMs != endMs && endsAtMidnight &&
         ((flags & DateUtilsBridge.FORMAT_SHOW_TIME) == 0
             || DateUtilsBridge.dayDistance(startCalendar, endCalendar) <= 1)) {
-      endCalendar.roll(Calendar.DAY_OF_MONTH, false);
+      endCalendar.add(Calendar.DAY_OF_MONTH, -1);
     }
 
     String skeleton = DateUtilsBridge.toSkeleton(startCalendar, endCalendar, flags);
diff --git a/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java b/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java
index 6e0bce6..4c22371 100644
--- a/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java
+++ b/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java
@@ -429,7 +429,7 @@
     final ULocale locale = new ULocale("en");
     final TimeZone timeZone = TimeZone.getTimeZone("UTC");
 
-    assertEquals("April 30, 11:00 PM – May 1, 12:00 AM", formatDateRange(locale, timeZone,
+    assertEquals("11:00 PM – 12:00 AM", formatDateRange(locale, timeZone,
             1430434800000L, 1430438400000L, FORMAT_SHOW_TIME));
   }
 }