use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_datetime_YMDH.
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
public void testForFields_datetime_YMDH() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear(), DateTimeFieldType.dayOfMonth(), DateTimeFieldType.hourOfDay() };
int[] values = new int[] { 2005, 6, 25, 12 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("2005-06-25T12", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("2005-06-25T12", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("20050625T12", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("20050625T12", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
}
use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_weekBased_D.
//-----------------------------------------------------------------------
public void testForFields_weekBased_D() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.dayOfWeek() };
int[] values = new int[] { 5 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("-W-5", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("-W-5", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("-W-5", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("-W-5", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
}
use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_time_H.
//-----------------------------------------------------------------------
public void testForFields_time_H() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.hourOfDay() };
int[] values = new int[] { 10 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("10", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("10", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("10", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("10", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
}
use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_calBased_Y.
//-----------------------------------------------------------------------
public void testForFields_calBased_Y() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.year() };
int[] values = new int[] { 2005 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("2005", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("2005", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("2005", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("2005", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
}
use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_time_HSm.
//-----------------------------------------------------------------------
public void testForFields_time_HSm() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.hourOfDay(), DateTimeFieldType.secondOfMinute(), DateTimeFieldType.millisOfSecond() };
int[] values = new int[] { 10, 30, 40 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("10-30.040", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("10-30.040", 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