Search in sources :

Example 21 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_chrono.

public void testParseInto_chrono() {
    MutableDateTime expect = null;
    MutableDateTime result = null;
    expect = new MutableDateTime(2004, 6, 9, 12, 20, 30, 0, PARIS);
    result = new MutableDateTime(0L);
    assertEquals(20, g.withChronology(ISO_PARIS).parseInto(result, "2004-06-09T10:20:30Z", 0));
    assertEquals(expect, result);
    expect = new MutableDateTime(2004, 6, 9, 11, 20, 30, 0, LONDON);
    result = new MutableDateTime(0L);
    assertEquals(20, g.withChronology(null).parseInto(result, "2004-06-09T10:20:30Z", 0));
    assertEquals(expect, result);
    expect = new MutableDateTime(2547, 6, 9, 12, 20, 30, 0, BUDDHIST_PARIS);
    result = new MutableDateTime(0L);
    assertEquals(20, g.withChronology(BUDDHIST_PARIS).parseInto(result, "2547-06-09T10:20:30Z", 0));
    assertEquals(expect, result);
    expect = new MutableDateTime(2004, 6, 9, 10, 29, 51, 0, BUDDHIST_PARIS);
    result = new MutableDateTime(0L);
    assertEquals(20, g.withChronology(BUDDHIST_PARIS).parseInto(result, "2004-06-09T10:20:30Z", 0));
    assertEquals(expect, result);
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Example 22 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_zone.

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

Example 23 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_zone2.

public void testParseInto_zone2() {
    MutableDateTime expect = null;
    MutableDateTime result = null;
    expect = new MutableDateTime(2004, 6, 9, 11, 20, 30, 0, LONDON);
    result = new MutableDateTime(0L);
    assertEquals(25, g.withZone(LONDON).parseInto(result, "2004-06-09T06:20:30-04:00", 0));
    assertEquals(expect, result);
    expect = new MutableDateTime(2004, 6, 9, 11, 20, 30, 0, LONDON);
    assertEquals(25, g.withZone(null).parseInto(result, "2004-06-09T06:20:30-04:00", 0));
    assertEquals(expect, result);
    expect = new MutableDateTime(2004, 6, 9, 12, 20, 30, 0, PARIS);
    assertEquals(25, g.withZone(PARIS).parseInto(result, "2004-06-09T06:20:30-04:00", 0));
    assertEquals(expect, result);
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Example 24 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_monthDay_feb29_newYork.

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

Example 25 with MutableDateTime

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

the class TestDateTimeFormatter method testParseMutableDateTime_zone3.

public void testParseMutableDateTime_zone3() {
    DateTimeFormatter h = new DateTimeFormatterBuilder().append(ISODateTimeFormat.date()).appendLiteral('T').append(ISODateTimeFormat.timeElementParser()).toFormatter();
    MutableDateTime expect = null;
    expect = new MutableDateTime(2004, 6, 9, 10, 20, 30, 0, LONDON);
    assertEquals(expect, h.withZone(LONDON).parseMutableDateTime("2004-06-09T10:20:30"));
    expect = new MutableDateTime(2004, 6, 9, 10, 20, 30, 0, LONDON);
    assertEquals(expect, h.withZone(null).parseMutableDateTime("2004-06-09T10:20:30"));
    expect = new MutableDateTime(2004, 6, 9, 10, 20, 30, 0, PARIS);
    assertEquals(expect, h.withZone(PARIS).parseMutableDateTime("2004-06-09T10:20:30"));
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Aggregations

MutableDateTime (org.joda.time.MutableDateTime)76 DateTime (org.joda.time.DateTime)12 Instant (org.joda.time.Instant)6 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)6 Date (java.util.Date)5 Chronology (org.joda.time.Chronology)4 DateTimeZone (org.joda.time.DateTimeZone)4 ISOChronology (org.joda.time.chrono.ISOChronology)4 Test (org.junit.Test)4 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 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1