use of java.time.Period in project drools by kiegroup.
the class RangeNode method convertToComparable.
private Comparable convertToComparable(EvaluationContext ctx, Object s) {
Comparable start;
if (s == null) {
start = null;
} else if (s instanceof Comparable) {
start = (Comparable) s;
} else if (s instanceof Period) {
// period has special semantics
start = new ComparablePeriod((Period) s);
} else {
ctx.notifyEvt(astEvent(Severity.ERROR, Msg.createMessage(Msg.INCOMPATIBLE_TYPE_FOR_RANGE, s.getClass().getSimpleName())));
start = null;
}
return start;
}
use of java.time.Period in project mapstruct by mapstruct.
the class Java8TimeConversionTest method testStringToPeriodNullMapping.
@ProcessorTest
public void testStringToPeriodNullMapping() {
Target target = new Target();
target.setForPeriodConversionWithString(null);
Source source = SourceTargetMapper.INSTANCE.targetToSource(target);
Period period = source.getForPeriodConversionWithString();
assertThat(period).isNull();
}
use of java.time.Period in project jdk8u_jdk by JetBrains.
the class TCKPeriod method test_hashCode.
//-----------------------------------------------------------------------
public void test_hashCode() {
Period test5 = Period.ofDays(5);
Period test6 = Period.ofDays(6);
Period test5M = Period.ofMonths(5);
Period test5Y = Period.ofYears(5);
assertEquals(test5.hashCode() == test5.hashCode(), true);
assertEquals(test5.hashCode() == test6.hashCode(), false);
}
use of java.time.Period in project jdk8u_jdk by JetBrains.
the class TCKPeriod method test_bad_getUnit.
@Test(dataProvider = "BadTemporalUnit", expectedExceptions = DateTimeException.class)
public void test_bad_getUnit(TemporalUnit unit) {
Period period = Period.of(2, 2, 2);
period.get(unit);
}
use of java.time.Period in project jdk8u_jdk by JetBrains.
the class TCKPeriod method test_equals_otherClass.
public void test_equals_otherClass() {
Period test = Period.of(1, 2, 3);
assertEquals(test.equals(""), false);
}
Aggregations