use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_time_M.
//-----------------------------------------------------------------------
public void testForFields_time_M() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.minuteOfHour() };
int[] values = new int[] { 20 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("-20", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("-20", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, true);
assertEquals("-20", f.print(new Partial(fields, values)));
assertEquals(0, types.size());
types = new ArrayList(Arrays.asList(fields));
f = ISODateTimeFormat.forFields(types, false, false);
assertEquals("-20", 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_YMD_unmodifiable.
//-----------------------------------------------------------------------
public void testForFields_calBased_YMD_unmodifiable() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear(), DateTimeFieldType.dayOfMonth() };
int[] values = new int[] { 2005, 6, 25 };
List types = Collections.unmodifiableList(new ArrayList(Arrays.asList(fields)));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("2005-06-25", f.print(new Partial(fields, values)));
assertEquals(3, types.size());
types = Arrays.asList(fields);
f = ISODateTimeFormat.forFields(types, true, true);
assertEquals("2005-06-25", f.print(new Partial(fields, values)));
assertEquals(3, types.size());
}
use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISODateTimeFormat_Fields method testForFields_weekBased_YD.
//-----------------------------------------------------------------------
public void testForFields_weekBased_YD() {
DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.weekyear(), DateTimeFieldType.dayOfWeek() };
int[] values = new int[] { 2005, 5 };
List types = new ArrayList(Arrays.asList(fields));
DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
assertEquals("2005-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("2005W-5", 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 CoreNLP by stanfordnlp.
the class SUTimeTest method testResolveDowToDay.
@Test
public void testResolveDowToDay() {
Partial p = new Partial(JodaTimeUtils.standardISOWeekFields, new int[] { 2016, 1, 1, 0, 0, 0, 0 });
assertEquals("[year=2016, weekOfWeekyear=1, dayOfWeek=1, hourOfDay=0, minuteOfHour=0, secondOfMinute=0, millisOfSecond=0]", p.toString());
Partial p2 = JodaTimeUtils.resolveDowToDay(p);
assertEquals("2016-01-04T00:00:00.000", p2.toString());
}
use of org.joda.time.Partial in project joda-time by JodaOrg.
the class TestISOChronology method testPartialDayOfYearAdd.
public void testPartialDayOfYearAdd() {
Partial start = new Partial().with(DateTimeFieldType.year(), 2000).with(DateTimeFieldType.dayOfYear(), 366);
Partial end = new Partial().with(DateTimeFieldType.year(), 2004).with(DateTimeFieldType.dayOfYear(), 366);
assertEquals(end, start.withFieldAdded(DurationFieldType.days(), 365 + 365 + 365 + 366));
assertEquals(start, end.withFieldAdded(DurationFieldType.days(), -(365 + 365 + 365 + 366)));
}
Aggregations