diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java b/icu4j/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java index 547cbed9edc..1705ec99044 100644 --- a/icu4j/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java @@ -120,6 +120,27 @@ public class ICUDurationTest extends TestFmwk { } else { errln("FAIL: got " + out + " wanted " + expected + " from " + d); } + // test 3 + d = factory.newDuration("P0DT0H0M10.0S"); + df = DurationFormat.getInstance(new ULocale("en")); + expected = "10 seconds"; + out = df.format(d); + if(out.equals(expected)) { + logln("out=expected: " + expected + " from " + d); + } else { + errln("FAIL: got " + out + " wanted " + expected + " from " + d); + } + // test 4 + d = factory.newDuration(86400000); + df = DurationFormat.getInstance(new ULocale("en")); + expected = "1 day, 0 hours, 0 minutes, and 0 seconds"; + out = df.format(d); + if(out.equals(expected)) { + logln("out=expected: " + expected + " from " + d); + } else { + errln("FAIL: got " + out + " wanted " + expected + " from " + d); + } + } diff --git a/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormat.java b/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormat.java index 7596ddf400d..8fb6f5e5055 100644 --- a/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormat.java +++ b/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormat.java @@ -133,9 +133,15 @@ public class BasicDurationFormat extends DurationFormat { inPast = true; } // convert a Duration to a Period + boolean sawNonZero = false; // did we have a set, non-zero field? for(int i=0;i