Search in sources :

Example 16 with Chronology

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

the class TestReadableInstantConverter method testGetChronology_Object_nullChronology.

public void testGetChronology_Object_nullChronology() throws Exception {
    assertEquals(ISO.withUTC(), ReadableInstantConverter.INSTANCE.getChronology(new Instant(123L), (Chronology) null));
    assertEquals(ISO, ReadableInstantConverter.INSTANCE.getChronology(new DateTime(123L), (Chronology) null));
    MutableDateTime mdt = new MutableDateTime() {

        public Chronology getChronology() {
            // bad
            return null;
        }
    };
    assertEquals(ISO, ReadableInstantConverter.INSTANCE.getChronology(mdt, (Chronology) null));
}
Also used : ReadableInstant(org.joda.time.ReadableInstant) Instant(org.joda.time.Instant) MutableDateTime(org.joda.time.MutableDateTime) Chronology(org.joda.time.Chronology) ISOChronology(org.joda.time.chrono.ISOChronology) JulianChronology(org.joda.time.chrono.JulianChronology) DateTime(org.joda.time.DateTime) MutableDateTime(org.joda.time.MutableDateTime)

Example 17 with Chronology

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

the class TestLenientChronology method test_isoChrononolgy_Chicago.

public void test_isoChrononolgy_Chicago() {
    DateTimeZone zone = DateTimeZone.forID("America/Chicago");
    Chronology lenient = ISOChronology.getInstance(zone);
    try {
        new DateTime(2007, 3, 11, 2, 30, 0, 0, lenient);
        fail();
    } catch (IllegalArgumentException ex) {
    // expected
    }
}
Also used : Chronology(org.joda.time.Chronology) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime)

Example 18 with Chronology

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

the class TestLenientChronology method test_lenientChrononolgy_Turk.

public void test_lenientChrononolgy_Turk() {
    Chronology lenient = LenientChronology.getInstance(ISOChronology.getInstance(MOCK_TURK));
    DateTime dt = new DateTime(2007, 4, 1, 0, 30, 0, 0, lenient);
    assertEquals("2007-04-01T01:30:00.000-04:00", dt.toString());
}
Also used : Chronology(org.joda.time.Chronology) DateTime(org.joda.time.DateTime)

Example 19 with Chronology

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

the class TestLenientChronology method test_setYear.

//-----------------------------------------------------------------------
public void test_setYear() {
    Chronology zone = LenientChronology.getInstance(ISOChronology.getInstanceUTC());
    DateTime dt = new DateTime(2007, 1, 1, 0, 0, 0, 0, zone);
    assertEquals("2007-01-01T00:00:00.000Z", dt.toString());
    dt = dt.withYear(2008);
    assertEquals("2008-01-01T00:00:00.000Z", dt.toString());
}
Also used : Chronology(org.joda.time.Chronology) DateTime(org.joda.time.DateTime)

Example 20 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDate_monthDay_feb29.

public void testParseLocalDate_monthDay_feb29() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("M d").withChronology(chrono).withLocale(Locale.UK);
    assertEquals(new LocalDate(2000, 2, 29, chrono), f.parseLocalDate("2 29"));
}
Also used : Chronology(org.joda.time.Chronology) GJChronology(org.joda.time.chrono.GJChronology) ISOChronology(org.joda.time.chrono.ISOChronology) BuddhistChronology(org.joda.time.chrono.BuddhistChronology) LocalDate(org.joda.time.LocalDate)

Aggregations

Chronology (org.joda.time.Chronology)69 DateTime (org.joda.time.DateTime)32 ISOChronology (org.joda.time.chrono.ISOChronology)30 GJChronology (org.joda.time.chrono.GJChronology)18 BuddhistChronology (org.joda.time.chrono.BuddhistChronology)17 LocalDate (org.joda.time.LocalDate)14 DateTimeZone (org.joda.time.DateTimeZone)13 MutableDateTime (org.joda.time.MutableDateTime)7 LocalDateTime (org.joda.time.LocalDateTime)4 ReadableDateTime (org.joda.time.ReadableDateTime)4 JulianChronology (org.joda.time.chrono.JulianChronology)3 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)3 Serializable (java.io.Serializable)2 Date (java.util.Date)2 Duration (org.joda.time.Duration)2 Period (org.joda.time.Period)2 ReadableDuration (org.joda.time.ReadableDuration)2 ReadableInstant (org.joda.time.ReadableInstant)2 ReadablePartial (org.joda.time.ReadablePartial)2 Calendar (java.util.Calendar)1