Search in sources :

Example 66 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_monthDay_withDefaultYear_feb29.

public void testParseInto_monthDay_withDefaultYear_feb29() {
    DateTimeFormatter f = DateTimeFormat.forPattern("M d").withDefaultYear(2012);
    MutableDateTime result = new MutableDateTime(2004, 1, 9, 12, 20, 30, 0, LONDON);
    assertEquals(4, f.parseInto(result, "2 29", 0));
    assertEquals(new MutableDateTime(2004, 2, 29, 12, 20, 30, 0, LONDON), result);
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Example 67 with MutableDateTime

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

the class TestDateTimeFormatter method testParseMutableDateTime_simple.

//-----------------------------------------------------------------------
public void testParseMutableDateTime_simple() {
    MutableDateTime expect = null;
    expect = new MutableDateTime(2004, 6, 9, 11, 20, 30, 0, LONDON);
    assertEquals(expect, g.parseMutableDateTime("2004-06-09T10:20:30Z"));
    try {
        g.parseMutableDateTime("ABC");
        fail();
    } catch (IllegalArgumentException ex) {
    }
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Example 68 with MutableDateTime

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

the class TestDateTimeFormatter method testParseMutableDateTime_zone.

public void testParseMutableDateTime_zone() {
    MutableDateTime expect = null;
    expect = new MutableDateTime(2004, 6, 9, 11, 20, 30, 0, LONDON);
    assertEquals(expect, g.withZone(LONDON).parseMutableDateTime("2004-06-09T10:20:30Z"));
    expect = new MutableDateTime(2004, 6, 9, 11, 20, 30, 0, LONDON);
    assertEquals(expect, g.withZone(null).parseMutableDateTime("2004-06-09T10:20:30Z"));
    expect = new MutableDateTime(2004, 6, 9, 12, 20, 30, 0, PARIS);
    assertEquals(expect, g.withZone(PARIS).parseMutableDateTime("2004-06-09T10:20:30Z"));
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Example 69 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_simple_precedence.

public void testParseInto_simple_precedence() {
    MutableDateTime expect = null;
    MutableDateTime result = null;
    expect = new MutableDateTime(2004, 6, 7, 11, 20, 30, 0, LONDON);
    result = new MutableDateTime(0L);
    // DayOfWeek takes precedence, because week < month in length
    assertEquals(24, f.parseInto(result, "Mon 2004-06-09T10:20:30Z", 0));
    assertEquals(expect, result);
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Example 70 with MutableDateTime

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

the class TestDateTimeFormatter method testParseMutableDateTime_offsetParsed.

public void testParseMutableDateTime_offsetParsed() {
    MutableDateTime expect = null;
    expect = new MutableDateTime(2004, 6, 9, 10, 20, 30, 0, UTC);
    assertEquals(expect, g.withOffsetParsed().parseMutableDateTime("2004-06-09T10:20:30Z"));
    expect = new MutableDateTime(2004, 6, 9, 6, 20, 30, 0, DateTimeZone.forOffsetHours(-4));
    assertEquals(expect, g.withOffsetParsed().parseMutableDateTime("2004-06-09T06:20:30-04:00"));
    expect = new MutableDateTime(2004, 6, 9, 10, 20, 30, 0, UTC);
    assertEquals(expect, g.withZone(PARIS).withOffsetParsed().parseMutableDateTime("2004-06-09T10:20:30Z"));
    expect = new MutableDateTime(2004, 6, 9, 12, 20, 30, 0, PARIS);
    assertEquals(expect, g.withOffsetParsed().withZone(PARIS).parseMutableDateTime("2004-06-09T10:20:30Z"));
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Aggregations

MutableDateTime (org.joda.time.MutableDateTime)79 DateTime (org.joda.time.DateTime)13 Date (java.util.Date)6 Instant (org.joda.time.Instant)6 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)6 Chronology (org.joda.time.Chronology)4 DateTimeZone (org.joda.time.DateTimeZone)4 ISOChronology (org.joda.time.chrono.ISOChronology)4 Test (org.junit.Test)4 Timestamp (java.sql.Timestamp)3 ArrayList (java.util.ArrayList)3 IntervalWindow (org.apache.beam.sdk.transforms.windowing.IntervalWindow)3 SlidingWindows (org.apache.beam.sdk.transforms.windowing.SlidingWindows)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 KV (org.apache.beam.sdk.values.KV)2 TimestampedValue (org.apache.beam.sdk.values.TimestampedValue)2 Duration (org.joda.time.Duration)2 Category (org.junit.experimental.categories.Category)2