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

The following examples show how to use org.joda.time.DateTimeFieldType#monthOfYear() . 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_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 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_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 5
Source File: GJLocaleSymbols.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public int monthOfYearTextToValue(String text) {
    Integer month = iParseMonths.get(text);
    if (month != null) {
        return month.intValue();
    }
    throw new IllegalFieldValueException(DateTimeFieldType.monthOfYear(), text);
}
 
Example 6
Source File: BasicMonthOfYearDateTimeField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
Example 7
Source File: GJLocaleSymbols.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public int monthOfYearTextToValue(String text) {
    Integer month = iParseMonths.get(text);
    if (month != null) {
        return month.intValue();
    }
    throw new IllegalFieldValueException(DateTimeFieldType.monthOfYear(), text);
}
 
Example 8
Source File: BasicMonthOfYearDateTimeField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
Example 9
Source File: Time_14_BasicMonthOfYearDateTimeField_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
Example 10
Source File: Time_14_BasicMonthOfYearDateTimeField_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
Example 11
Source File: patch1-Time-14-Nopol2017_patch1-Time-14-Nopol2017_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
Example 12
Source File: patch1-Time-14-Nopol2017_patch1-Time-14-Nopol2017_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
Example 13
Source File: Nopol2017_0086_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
Example 14
Source File: Nopol2017_0086_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
Example 15
Source File: DayOfMonthOfFixedYearDateTimeField.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public int getMaximumValue(ReadablePartial partial, int[] values) {
  int size = partial.size();
  for (int i = 0; i < size; i++) {
    if (partial.getFieldType(i) == DateTimeFieldType.monthOfYear()) {
      int month = values[i];
      return this.daysInMonth[month - 1];
    }
  }
  return this.getMaximumValue();
}
 
Example 16
Source File: TestGJMonthOfYearField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public TestGJMonthOfYearField(TestGJChronology chrono) {
    super(DateTimeFieldType.monthOfYear(), chrono.millisPerMonth(), chrono);
}
 
Example 17
Source File: CalendarEntryBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static Partial getPartialFromString(String date) {
    Integer month = Integer.valueOf(date.substring(0, 2));
    Integer year = Integer.valueOf(date.substring(2));
    return new Partial(new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() }, new int[] {
            year.intValue(), month.intValue() });
}
 
Example 18
Source File: TestGJMonthOfYearField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public TestGJMonthOfYearField(TestGJChronology chrono) {
    super(DateTimeFieldType.monthOfYear(), chrono.millisPerMonth(), chrono);
}
 
Example 19
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 20
Source File: CalendarEntryBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static Partial getPartialFromYearMonthDay(YearMonthDay day) {
    return new Partial(new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() }, new int[] {
            day.getYear(), day.getMonthOfYear() });
}