Search in sources :

Example 16 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_monthOnly_baseStartYear.

public void testParseInto_monthOnly_baseStartYear() {
    DateTimeFormatter f = DateTimeFormat.forPattern("M").withLocale(Locale.UK);
    MutableDateTime result = new MutableDateTime(2004, 1, 1, 12, 20, 30, 0, TOKYO);
    assertEquals(1, f.parseInto(result, "5", 0));
    assertEquals(new MutableDateTime(2004, 5, 1, 12, 20, 30, 0, TOKYO), result);
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Example 17 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_monthDay_feb29_OfYear.

public void testParseInto_monthDay_feb29_OfYear() {
    DateTimeFormatter f = DateTimeFormat.forPattern("M d").withLocale(Locale.UK);
    MutableDateTime result = new MutableDateTime(2004, 12, 31, 23, 59, 59, 999, LONDON);
    assertEquals(4, f.parseInto(result, "2 29", 0));
    assertEquals(new MutableDateTime(2004, 2, 29, 23, 59, 59, 999, LONDON), result);
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Example 18 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_offsetParsed.

public void testParseInto_offsetParsed() {
    MutableDateTime expect = null;
    MutableDateTime result = null;
    expect = new MutableDateTime(2004, 6, 9, 10, 20, 30, 0, UTC);
    result = new MutableDateTime(0L);
    assertEquals(20, g.withOffsetParsed().parseInto(result, "2004-06-09T10:20:30Z", 0));
    assertEquals(expect, result);
    expect = new MutableDateTime(2004, 6, 9, 6, 20, 30, 0, DateTimeZone.forOffsetHours(-4));
    result = new MutableDateTime(0L);
    assertEquals(25, g.withOffsetParsed().parseInto(result, "2004-06-09T06:20:30-04:00", 0));
    assertEquals(expect, result);
    expect = new MutableDateTime(2004, 6, 9, 10, 20, 30, 0, UTC);
    result = new MutableDateTime(0L);
    assertEquals(20, g.withZone(PARIS).withOffsetParsed().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.withOffsetParsed().withZone(PARIS).parseInto(result, "2004-06-09T10:20:30Z", 0));
    assertEquals(expect, result);
}
Also used : MutableDateTime(org.joda.time.MutableDateTime)

Example 19 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_zone3.

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

Example 20 with MutableDateTime

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

the class TestDateTimeFormatter method testParseInto_monthOnly_baseEndYear.

public void testParseInto_monthOnly_baseEndYear() {
    DateTimeFormatter f = DateTimeFormat.forPattern("M").withLocale(Locale.UK);
    MutableDateTime result = new MutableDateTime(2004, 12, 31, 12, 20, 30, 0, TOKYO);
    assertEquals(1, f.parseInto(result, "5", 0));
    assertEquals(new MutableDateTime(2004, 5, 31, 12, 20, 30, 0, TOKYO), result);
}
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