Java Code Examples for org.joda.time.DateTime#dayOfYear()

The following examples show how to use org.joda.time.DateTime#dayOfYear() . 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: DatetimeUtil.java    From stategen with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Gets the start datetime.
 *
 * @param curr the curr
 * @param type the type
 * @return the start datetime
 */
protected static DateTime startDateTime(DateTime curr, DateType type) {
    DateTime result = curr;
    Property pr = null;
    if (DateType.YEAR.equals(type)) {
        pr = curr.dayOfYear();
        result = pr.withMinimumValue().withTimeAtStartOfDay();
    } else if (DateType.MONTH.equals(type)) {
        pr = curr.dayOfMonth();
        result = pr.withMinimumValue().withTimeAtStartOfDay();
    } else if (DateType.WEEK.equals(type)) {
        pr = curr.dayOfWeek();
        result = pr.withMinimumValue().withTimeAtStartOfDay();
    } else if (DateType.DAY.equals(type)) {
        pr = curr.hourOfDay();
        result = pr.withMinimumValue().withTimeAtStartOfDay();
    } else if (DateType.HOUR.equals(type)) {
        pr = curr.minuteOfHour();
        result = pr.withMinimumValue().withMinuteOfHour(0).withSecondOfMinute(0)
            .withMillisOfSecond(0);
    } else if (DateType.MINUTE.equals(type)) {
        pr = curr.secondOfMinute();
        result = pr.withMinimumValue().withSecondOfMinute(0).withMillisOfSecond(0);
    } else if (DateType.SECOND.equals(type)) {
        pr = curr.millisOfSecond();
        result = pr.withMinimumValue().withMillisOfSecond(0);
    }
    return result;
}
 
Example 2
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate1() {
    DateTime dt = new DateTime(1945, 11, 12, 0, 0, 0, 0, ISO_UTC);
    dt = dt.withChronology(ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    assertEquals(14, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(64, dt.getYearOfCentury());
    assertEquals(1364, dt.getYearOfEra());
    
    assertEquals(1364, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1365, 12, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(12, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1365, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    assertEquals(new DateTime(1364, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addWrapFieldToCopy(1));
    
    assertEquals(6, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(29, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.MONDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(6 * 30 + 5 * 29 + 6, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(354, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 3
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate2() {
    DateTime dt = new DateTime(2005, 11, 26, 0, 0, 0, 0, ISO_UTC);
    dt = dt.withChronology(ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    assertEquals(15, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(26, dt.getYearOfCentury());
    assertEquals(1426, dt.getYearOfEra());
    
    assertEquals(1426, dt.getYear());
    Property fld = dt.year();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    
    assertEquals(24, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(29, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    
    assertEquals(DateTimeConstants.SATURDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    
    assertEquals(5 * 30 + 4 * 29 + 24, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(355, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 4
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate3() {
    DateTime dt = new DateTime(1426, 12, 24, 0, 0, 0, 0, ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    
    assertEquals(1426, dt.getYear());
    Property fld = dt.year();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    
    assertEquals(12, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    
    assertEquals(24, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    
    assertEquals(DateTimeConstants.TUESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    
    assertEquals(6 * 30 + 5 * 29 + 24, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(355, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 5
Source File: TestCopticChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate() {
    DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(COPTIC_UTC);
    assertEquals(CopticChronology.AM, dt.getEra());
    assertEquals(18, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(20, dt.getYearOfCentury());
    assertEquals(1720, dt.getYearOfEra());
    
    assertEquals(1720, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1721, 10, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(13, fld.getMaximumValue());
    assertEquals(13, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1721, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(4));
    assertEquals(new DateTime(1720, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addWrapFieldToCopy(4));
    
    assertEquals(2, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(9 * 30 + 2, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(365, fld.getMaximumValue());
    assertEquals(366, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 6
Source File: TestEthiopicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate() {
    DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(ETHIOPIC_UTC);
    assertEquals(EthiopicChronology.EE, dt.getEra());
    assertEquals(20, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(96, dt.getYearOfCentury());
    assertEquals(1996, dt.getYearOfEra());
    
    assertEquals(1996, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1997, 10, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(13, fld.getMaximumValue());
    assertEquals(13, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1997, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(4));
    assertEquals(new DateTime(1996, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addWrapFieldToCopy(4));
    
    assertEquals(2, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(9 * 30 + 2, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(365, fld.getMaximumValue());
    assertEquals(366, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 7
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate1() {
    DateTime dt = new DateTime(1945, 11, 12, 0, 0, 0, 0, ISO_UTC);
    dt = dt.withChronology(ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    assertEquals(14, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(64, dt.getYearOfCentury());
    assertEquals(1364, dt.getYearOfEra());
    
    assertEquals(1364, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1365, 12, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(12, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1365, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    assertEquals(new DateTime(1364, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addWrapFieldToCopy(1));
    
    assertEquals(6, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(29, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.MONDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(6 * 30 + 5 * 29 + 6, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(354, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 8
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate2() {
    DateTime dt = new DateTime(2005, 11, 26, 0, 0, 0, 0, ISO_UTC);
    dt = dt.withChronology(ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    assertEquals(15, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(26, dt.getYearOfCentury());
    assertEquals(1426, dt.getYearOfEra());
    
    assertEquals(1426, dt.getYear());
    Property fld = dt.year();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    
    assertEquals(24, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(29, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    
    assertEquals(DateTimeConstants.SATURDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    
    assertEquals(5 * 30 + 4 * 29 + 24, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(355, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 9
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate3() {
    DateTime dt = new DateTime(1426, 12, 24, 0, 0, 0, 0, ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    
    assertEquals(1426, dt.getYear());
    Property fld = dt.year();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    
    assertEquals(12, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    
    assertEquals(24, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    
    assertEquals(DateTimeConstants.TUESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    
    assertEquals(6 * 30 + 5 * 29 + 24, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(355, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 10
Source File: TestCopticChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate() {
    DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(COPTIC_UTC);
    assertEquals(CopticChronology.AM, dt.getEra());
    assertEquals(18, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(20, dt.getYearOfCentury());
    assertEquals(1720, dt.getYearOfEra());
    
    assertEquals(1720, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1721, 10, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(13, fld.getMaximumValue());
    assertEquals(13, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1721, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(4));
    assertEquals(new DateTime(1720, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addWrapFieldToCopy(4));
    
    assertEquals(2, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(9 * 30 + 2, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(365, fld.getMaximumValue());
    assertEquals(366, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 11
Source File: TestEthiopicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate() {
    DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(ETHIOPIC_UTC);
    assertEquals(EthiopicChronology.EE, dt.getEra());
    assertEquals(20, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(96, dt.getYearOfCentury());
    assertEquals(1996, dt.getYearOfEra());
    
    assertEquals(1996, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1997, 10, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(13, fld.getMaximumValue());
    assertEquals(13, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1997, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(4));
    assertEquals(new DateTime(1996, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addWrapFieldToCopy(4));
    
    assertEquals(2, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(9 * 30 + 2, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(365, fld.getMaximumValue());
    assertEquals(366, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}