ICU-9914 DateIntervalFormat to handle 2 year vs. 4 year formats in ICU4J.

X-SVN-Rev: 33447
This commit is contained in:
Travis Keep 2013-03-21 16:43:17 +00:00
parent 1f65c0e70a
commit b33cab0a51
2 changed files with 36 additions and 1 deletions

View file

@ -1229,7 +1229,9 @@ public class DateIntervalFormat extends UFormat {
/* generate normalized form for date*/
if ( yCount != 0 ) {
normalizedDateSkeleton.append('y');
for (i = 0; i < yCount; i++) {
normalizedDateSkeleton.append('y');
}
}
if ( MCount != 0 ) {
if ( MCount < 3 ) {

View file

@ -1358,4 +1358,37 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk {
dif.format(from, to, new StringBuffer(), new FieldPosition(0))
.toString());
}
public void TestTicket9914() {
DateIntervalInfo dateIntervalInfo =
new DateIntervalInfo(ULocale.ENGLISH);
Calendar from = Calendar.getInstance();
Calendar to = Calendar.getInstance();
from.set(113, 3, 26);
to.set(113, 3, 28);
DateIntervalFormat dif = DateIntervalFormat.getInstance(
"yyyyMd", ULocale.ENGLISH, dateIntervalInfo);
assertEquals(
"yyyyMd skeleton.",
"4/26/0113 \u2013 4/28/0113",
dif.format(from, to, new StringBuffer(), new FieldPosition(0))
.toString());
dif = DateIntervalFormat.getInstance(
"yyMd", ULocale.ENGLISH, dateIntervalInfo);
assertEquals(
"yyMd skeleton.",
"4/26/13 \u2013 4/28/13",
dif.format(from, to, new StringBuffer(), new FieldPosition(0))
.toString());
dif = DateIntervalFormat.getInstance(
"yMd", ULocale.ENGLISH, dateIntervalInfo);
assertEquals(
"yMd skeleton.",
"4/26/113 \u2013 4/28/113",
dif.format(from, to, new StringBuffer(), new FieldPosition(0))
.toString());
}
}