Java Code Examples for org.joda.time.DateTimeFieldType#dayOfMonth()

The following examples show how to use org.joda.time.DateTimeFieldType#dayOfMonth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestISODateTimeFormat_Fields.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
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());
}
 
Example 2
Source File: TestISODateTimeFormat_Fields.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
public void testForFields_calBased_YMD_duplicates() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
            DateTimeFieldType.monthOfYear(),
            DateTimeFieldType.dayOfMonth(),
    };
    DateTimeFieldType[] dupFields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
            DateTimeFieldType.monthOfYear(),
            DateTimeFieldType.dayOfMonth(),
            DateTimeFieldType.monthOfYear(),
    };
    int[] values = new int[] {2005, 6, 25};
    List types = new ArrayList(Arrays.asList(dupFields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06-25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    
    types = Arrays.asList(dupFields);
    f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06-25", f.print(new Partial(fields, values)));
    assertEquals(4, types.size());
}
 
Example 3
Source File: TestISODateTimeFormat_Fields.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
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());
}
 
Example 4
Source File: TestISODateTimeFormat_Fields.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
public void testForFields_calBased_YMD_duplicates() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
            DateTimeFieldType.monthOfYear(),
            DateTimeFieldType.dayOfMonth(),
    };
    DateTimeFieldType[] dupFields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
            DateTimeFieldType.monthOfYear(),
            DateTimeFieldType.dayOfMonth(),
            DateTimeFieldType.monthOfYear(),
    };
    int[] values = new int[] {2005, 6, 25};
    List types = new ArrayList(Arrays.asList(dupFields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06-25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
    
    types = Arrays.asList(dupFields);
    f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06-25", f.print(new Partial(fields, values)));
    assertEquals(4, types.size());
}
 
Example 5
Source File: DayOfMonthOfFixedYearDateTimeField.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public DayOfMonthOfFixedYearDateTimeField(FixedYearVariableMonthChronology chron) {
  super(DateTimeFieldType.dayOfMonth(), chron.days());
  this.chron = chron;

  this.daysInMonth = chron.getMonthLengths();
  this.maxValue = daysInMonth[0];
  for (int i = 1; i < daysInMonth.length; i++) {
    this.maxValue = Math.max(this.maxValue, daysInMonth[i]);
  }
}
 
Example 6
Source File: BasicDayOfMonthDateTimeField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Restricted constructor.
 */
BasicDayOfMonthDateTimeField(BasicChronology chronology, DurationField days) {
    super(DateTimeFieldType.dayOfMonth(), days);
    iChronology = chronology;
}
 
Example 7
Source File: TestISODateTimeFormat.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testFormat_date_partial() {
    Partial dt = new Partial(
            new DateTimeFieldType[] {DateTimeFieldType.year(), DateTimeFieldType.monthOfYear(), DateTimeFieldType.dayOfMonth()},
            new int[] {2004, 6, 9});
    assertEquals("2004-06-09", ISODateTimeFormat.date().print(dt));
}
 
Example 8
Source File: TestGJDayOfMonthField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public TestGJDayOfMonthField(TestGJChronology chrono) {
    super(DateTimeFieldType.dayOfMonth(), TestGJChronology.MILLIS_PER_DAY, chrono);
}
 
Example 9
Source File: BasicDayOfMonthDateTimeField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Restricted constructor.
 */
BasicDayOfMonthDateTimeField(BasicChronology chronology, DurationField days) {
    super(DateTimeFieldType.dayOfMonth(), days);
    iChronology = chronology;
}
 
Example 10
Source File: TestISODateTimeFormat.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testFormat_date_partial() {
    Partial dt = new Partial(
            new DateTimeFieldType[] {DateTimeFieldType.year(), DateTimeFieldType.monthOfYear(), DateTimeFieldType.dayOfMonth()},
            new int[] {2004, 6, 9});
    assertEquals("2004-06-09", ISODateTimeFormat.date().print(dt));
}
 
Example 11
Source File: TestGJDayOfMonthField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public TestGJDayOfMonthField(TestGJChronology chrono) {
    super(DateTimeFieldType.dayOfMonth(), TestGJChronology.MILLIS_PER_DAY, chrono);
}