use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_time_Mm.
//-----------------------------------------------------------------------
public void testForFields_time_Mm() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.minuteOfHour(), DateTimeFieldType.millisOfSecond() };
int[] values = new int[] { 20, 40 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("-20-.040", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("-20-.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) {
}
}
use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_calBased_YD.
//-----------------------------------------------------------------------
public void testForFields_calBased_YD() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.dayOfMonth() };
int[] values = new int[] { 2005, 25 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("2005--25", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("2005--25", 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) {
}
}
use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_weekBased_W.
//-----------------------------------------------------------------------
public void testForFields_weekBased_W() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.weekOfWeekyear() };
int[] values = new int[] { 8 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("-W08", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("-W08", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("-W08", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("-W08", 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_ordinalBased_YD.
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
public void testForFields_ordinalBased_YD() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.dayOfYear() };
int[] values = new int[] { 2005, 177 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("2005-177", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("2005-177", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("2005177", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("2005177", 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_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());
}
Aggregations