class ModeShapeDateTimeValueFactory extends AbstractValueFactory<DateTime> implements DateTimeFactory {

    @Override
    public DateTime create( String value ) {
        if (value == null) return null;
        try {
            return new ModeShapeDateTime(value.trim());
        } catch (java.time.format.DateTimeParseException err) {
            // See if this string represents a LONG value ...
            try {
                Long longValue = Long.parseLong(value);
                return new ModeShapeDateTime(longValue);
            } catch (NumberFormatException e) {
                // Guess it wasn't a long value ...
                throw new ValueFormatException(value, getPropertyType(),
                                               GraphI18n.errorConvertingType.text(String.class.getSimpleName(),
                                                                                  org.modeshape.jcr.api.value.DateTime.class.getSimpleName(),
                                                                                  value), err);
            }
        }
    }

}

class ModeShapeDateTimeValueFactoryTest extends AbstractValueFactory<DateTime> {

    private static final DateTime TODAY;
    private static final DateTime LAST_YEAR;
    private ModeShapeDateTimeValueFactory factory;

    @Test
    public void shouldNotCreateDateFromIntegerValue() {

        assertThat(factory.create(10000), is(new ModeShapeDateTime(10000)));
    }

}