use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestDateTimeFormatter method testParseLocalDate_monthDay_withDefaultYear_feb29.
public void testParseLocalDate_monthDay_withDefaultYear_feb29() {
Chronology chrono = GJChronology.getInstanceUTC();
DateTimeFormatter f = DateTimeFormat.forPattern("M d").withChronology(chrono).withLocale(Locale.UK).withDefaultYear(2012);
assertEquals(new LocalDate(2012, 2, 29, chrono), f.parseLocalDate("2 29"));
}
use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestCopticChronology method testLeap_5_13.
public void testLeap_5_13() {
Chronology chrono = CopticChronology.getInstance();
DateTime dt = new DateTime(3, 13, 5, 0, 0, chrono);
assertEquals(true, dt.year().isLeap());
assertEquals(true, dt.monthOfYear().isLeap());
assertEquals(false, dt.dayOfMonth().isLeap());
assertEquals(false, dt.dayOfYear().isLeap());
}
use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestCopticChronology method testLeap_6_13.
public void testLeap_6_13() {
Chronology chrono = CopticChronology.getInstance();
DateTime dt = new DateTime(3, 13, 6, 0, 0, chrono);
assertEquals(true, dt.year().isLeap());
assertEquals(true, dt.monthOfYear().isLeap());
assertEquals(true, dt.dayOfMonth().isLeap());
assertEquals(true, dt.dayOfYear().isLeap());
}
use of org.joda.time.Chronology in project druid by druid-io.
the class ExprUtils method toPeriodGranularity.
static PeriodGranularity toPeriodGranularity(final Expr periodArg, @Nullable final Expr originArg, @Nullable final Expr timeZoneArg, final Expr.ObjectBinding bindings) {
final Period period = new Period(periodArg.eval(bindings).asString());
final DateTime origin;
final DateTimeZone timeZone;
if (timeZoneArg == null) {
timeZone = null;
} else {
final String value = timeZoneArg.eval(bindings).asString();
timeZone = value != null ? DateTimes.inferTzFromString(value) : null;
}
if (originArg == null) {
origin = null;
} else {
Chronology chronology = timeZone == null ? ISOChronology.getInstanceUTC() : ISOChronology.getInstance(timeZone);
final Object value = originArg.eval(bindings).value();
if (value instanceof String && NullHandling.isNullOrEquivalent((String) value)) {
// We get a blank string here, when sql compatible null handling is enabled
// and expression contains empty string for for origin
// e.g timestamp_floor(\"__time\",'PT1M','','UTC')
origin = null;
} else {
origin = value != null ? new DateTime(value, chronology) : null;
}
}
return new PeriodGranularity(period, origin, timeZone);
}
Aggregations