Search in sources :

Example 26 with Partial

use of org.joda.time.Partial in project joda-time by JodaOrg.

the class TestISODateTimeFormat_Fields method testForFields_datetime_DH.

//-----------------------------------------------------------------------
public void testForFields_datetime_DH() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.dayOfMonth(), DateTimeFieldType.hourOfDay() };
    int[] values = new int[] { 25, 12 };
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("---25T12", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("---25T12", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("---25T12", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("---25T12", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
Also used : Partial(org.joda.time.Partial) DateTimeFieldType(org.joda.time.DateTimeFieldType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 27 with Partial

use of org.joda.time.Partial in project joda-time by JodaOrg.

the class TestISODateTimeFormat_Fields method testForFields_time_Sm.

//-----------------------------------------------------------------------
public void testForFields_time_Sm() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.secondOfMinute(), DateTimeFieldType.millisOfSecond() };
    int[] values = new int[] { 30, 40 };
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("--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("--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("--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("--30.040", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
Also used : Partial(org.joda.time.Partial) DateTimeFieldType(org.joda.time.DateTimeFieldType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 28 with Partial

use of org.joda.time.Partial in project joda-time by JodaOrg.

the class TestISODateTimeFormat_Fields method testForFields_time_HM.

//-----------------------------------------------------------------------
public void testForFields_time_HM() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.hourOfDay(), DateTimeFieldType.minuteOfHour() };
    int[] values = new int[] { 10, 20 };
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("10:20", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("10:20", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("1020", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("1020", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
Also used : Partial(org.joda.time.Partial) DateTimeFieldType(org.joda.time.DateTimeFieldType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 29 with Partial

use of org.joda.time.Partial in project joda-time by JodaOrg.

the class TestISODateTimeFormat_Fields method testForFields_calBased_D.

//-----------------------------------------------------------------------
public void testForFields_calBased_D() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.dayOfMonth() };
    int[] values = new int[] { 25 };
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("---25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("---25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("---25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("---25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
Also used : Partial(org.joda.time.Partial) DateTimeFieldType(org.joda.time.DateTimeFieldType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 30 with Partial

use of org.joda.time.Partial in project joda-time by JodaOrg.

the class TestISODateTimeFormat_Fields method testForFields_calBased_YM.

//-----------------------------------------------------------------------
public void testForFields_calBased_YM() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() };
    int[] values = new int[] { 2005, 6 };
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06", 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", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("2005-06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("2005-06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
Also used : Partial(org.joda.time.Partial) DateTimeFieldType(org.joda.time.DateTimeFieldType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Partial (org.joda.time.Partial)43 ArrayList (java.util.ArrayList)38 List (java.util.List)38 DateTimeFieldType (org.joda.time.DateTimeFieldType)38 Test (org.junit.Test)1