use of org.joda.time.DateTimeFieldType in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_calBased_MD.
//-----------------------------------------------------------------------
public void testForFields_calBased_MD() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.monthOfYear(), DateTimeFieldType.dayOfMonth() };
int[] values = new int[] { 6, 25 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("--06-25", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("--06-25", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("--0625", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("--0625", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
}
use of org.joda.time.DateTimeFieldType in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_datetime_YH.
//-----------------------------------------------------------------------
public void testForFields_datetime_YH() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.hourOfDay() };
int[] values = new int[] { 2005, 12 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("2005T12", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("2005T12", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
try {
ISODateTimeFormat.forFields(types, true, true);
fail();
} catch (IllegalArgumentException ex) {
}
types = new ArrayList(Arrays.asList(fields));
try {
ISODateTimeFormat.forFields(types, false, true);
fail();
} catch (IllegalArgumentException ex) {
}
}
Aggregations