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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations