Search in sources :

Example 6 with YearMonthDay

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

the class TestGJChronology method testSubtractDays.

public void testSubtractDays() {
    // This is a test for a bug in version 1.0. The dayOfMonth range
    // duration field did not match the monthOfYear duration field. This
    // caused an exception to be thrown when subtracting days.
    DateTime dt = new DateTime(1112306400000L, GJChronology.getInstance(DateTimeZone.forID("Europe/Berlin")));
    YearMonthDay ymd = dt.toYearMonthDay();
    while (ymd.toDateTimeAtMidnight().getDayOfWeek() != DateTimeConstants.MONDAY) {
        ymd = ymd.minus(Period.days(1));
    }
}
Also used : YearMonthDay(org.joda.time.YearMonthDay) DateTime(org.joda.time.DateTime)

Example 7 with YearMonthDay

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

the class TestGJChronology method testPartialGetAsText.

public void testPartialGetAsText() {
    GJChronology chrono = GJChronology.getInstance(TOKYO);
    assertEquals("January", new YearMonthDay("2005-01-01", chrono).monthOfYear().getAsText());
    assertEquals("Jan", new YearMonthDay("2005-01-01", chrono).monthOfYear().getAsShortText());
}
Also used : YearMonthDay(org.joda.time.YearMonthDay)

Example 8 with YearMonthDay

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

the class TestGJChronology method testMaximumValue.

public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1, GJChronology.getInstance());
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
Also used : DateMidnight(org.joda.time.DateMidnight) YearMonthDay(org.joda.time.YearMonthDay)

Aggregations

YearMonthDay (org.joda.time.YearMonthDay)8 DateMidnight (org.joda.time.DateMidnight)3 DateTime (org.joda.time.DateTime)3 DurationField (org.joda.time.DurationField)2 Chronology (org.joda.time.Chronology)1 TimeOfDay (org.joda.time.TimeOfDay)1