use of org.joda.time.DateTimeFieldType in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_weekBased_WD.
//-----------------------------------------------------------------------
public void testForFields_weekBased_WD() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.weekOfWeekyear(), DateTimeFieldType.dayOfWeek() };
int[] values = new int[] { 8, 5 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("-W08-5", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("-W08-5", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("-W085", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("-W085", 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_ordinalBased_Y.
//-----------------------------------------------------------------------
public void testForFields_ordinalBased_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.DateTimeFieldType in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_time_MS.
//-----------------------------------------------------------------------
public void testForFields_time_MS() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.minuteOfHour(), DateTimeFieldType.secondOfMinute() };
int[] values = new int[] { 20, 30 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("-20:30", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("-20:30", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("-2030", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("-2030", 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_time_MSm.
//-----------------------------------------------------------------------
public void testForFields_time_MSm() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.minuteOfHour(), DateTimeFieldType.secondOfMinute(), DateTimeFieldType.millisOfSecond() };
int[] values = new int[] { 20, 30, 40 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("-20:30.040", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("-20:30.040", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("-2030.040", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("-2030.040", 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_time_HMm.
//-----------------------------------------------------------------------
public void testForFields_time_HMm() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.hourOfDay(), DateTimeFieldType.minuteOfHour(), DateTimeFieldType.millisOfSecond() };
int[] values = new int[] { 10, 20, 40 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("10: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("1020-.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