Search in sources :

Example 21 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDate_year_month_week_2011.

public void testParseLocalDate_year_month_week_2011() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("yyyy-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 22 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDate_year_month_week_2016.

public void testParseLocalDate_year_month_week_2016() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("yyyy-MM-ww").withChronology(chrono);
    assertEquals(new LocalDate(2016, 1, 4, chrono), f.parseLocalDate("2016-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 23 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDateTime_monthDay_feb29.

public void testParseLocalDateTime_monthDay_feb29() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("M d H m").withChronology(chrono).withLocale(Locale.UK);
    assertEquals(new LocalDateTime(2000, 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 24 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDate_year_month_week_2015.

public void testParseLocalDate_year_month_week_2015() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("yyyy-MM-ww").withChronology(chrono);
    // 2015-01-01 would be better, but this is OK
    assertEquals(new LocalDate(2014, 12, 29, chrono), f.parseLocalDate("2015-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 25 with Chronology

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

the class TestDateTimeFormatter method testParseLocalDate_yearOfCentury.

public void testParseLocalDate_yearOfCentury() {
    Chronology chrono = GJChronology.getInstanceUTC();
    DateTimeFormatter f = DateTimeFormat.forPattern("yy M d").withChronology(chrono).withLocale(Locale.UK).withPivotYear(2050);
    LocalDate date = new LocalDate(2050, 8, 4, chrono);
    assertEquals(date, f.parseLocalDate("50 8 4"));
}
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