Search in sources :

Example 61 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDate_weekyear_month_week_2012.

public void testParseLocalDate_weekyear_month_week_2012() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("xxxx-MM-ww").withChronology(chrono);
    assertEquals(new LocalDate(2012, 1, 2, chrono), f.parseLocalDate("2012-01-01"));
}
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)

Example 62 with Chronology

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

the class TestDateTimeFormat method testFormat_yearOfEraParse.

public void testFormat_yearOfEraParse() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("YYYY-MM GG").withChronology(chrono).withLocale(Locale.UK);
    DateTime dt = new DateTime(2005, 10, 1, 0, 0, 0, 0, chrono);
    assertEquals(dt, f.parseDateTime("2005-10 AD"));
    assertEquals(dt, f.parseDateTime("2005-10 CE"));
    dt = new DateTime(-2005, 10, 1, 0, 0, 0, 0, chrono);
    assertEquals(dt, f.parseDateTime("2005-10 BC"));
    assertEquals(dt, f.parseDateTime("2005-10 BCE"));
}
Also used : Chronology(org.joda.time.Chronology) GJChronology(org.joda.time.chrono.GJChronology) DateTime(org.joda.time.DateTime)

Example 63 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDate_weekyear_month_week_2011.

public void testParseLocalDate_weekyear_month_week_2011() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("xxxx-MM-ww").withChronology(chrono);
    assertEquals(new LocalDate(2011, 1, 3, chrono), f.parseLocalDate("2011-01-01"));
}
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)

Example 64 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDateTime_monthDay_withDefaultYear_feb29.

public void testParseLocalDateTime_monthDay_withDefaultYear_feb29() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("M d H m").withChronology(chrono).withLocale(Locale.UK).withDefaultYear(2012);
    assertEquals(new LocalDateTime(2012, 2, 29, 13, 40, 0, 0, chrono), f.parseLocalDateTime("2 29 13 40"));
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Chronology(org.joda.time.Chronology) GJChronology(org.joda.time.chrono.GJChronology) ISOChronology(org.joda.time.chrono.ISOChronology) BuddhistChronology(org.joda.time.chrono.BuddhistChronology)

Example 65 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDate_year_month_week_2010.

// This test fails, but since more related tests pass with the extra loop in DateTimeParserBucket
// I'm going to leave the change in and ignore this test
//    public void testParseLocalDate_weekyear_month_week_2013() {
//        Chronology chrono = GJChronology.getInstanceUTC();
//        DateTimeFormatter f = DateTimeFormat.forPattern("xxxx-MM-ww").withChronology(chrono);
//        assertEquals(new LocalDate(2012, 12, 31, chrono), f.parseLocalDate("2013-01-01"));
//    }
public void testParseLocalDate_year_month_week_2010() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("yyyy-MM-ww").withChronology(chrono);
    assertEquals(new LocalDate(2010, 1, 4, chrono), f.parseLocalDate("2010-01-01"));
}
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