org.springframework.data.convert.Jsr310Converters Java Examples

The following examples show how to use org.springframework.data.convert.Jsr310Converters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationAuditingMetadata.java    From spring-data-mybatis with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the given field has a type that is a supported date type.
 * @param field
 */
private void assertValidDateFieldType(Optional<Field> field) {

	field.ifPresent(it -> {

		if (SUPPORTED_DATE_TYPES.contains(it.getType().getName())) {
			return;
		}

		Class<?> type = it.getType();

		if (Jsr310Converters.supports(type)
				|| ThreeTenBackPortConverters.supports(type)) {
			return;
		}

		throw new IllegalStateException(String.format(
				"Found created/modified date field with type %s but only %s as well as java.time types are supported!",
				type, SUPPORTED_DATE_TYPES));
	});
}
 
Example #2
Source File: DefaultAuditableBeanWrapperFactory.java    From spring-data-mybatis with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link DateConvertingAuditableBeanWrapper}.
 */
public DateConvertingAuditableBeanWrapper() {

	DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();

	JodaTimeConverters.getConvertersToRegister()
			.forEach(conversionService::addConverter);
	Jsr310Converters.getConvertersToRegister()
			.forEach(conversionService::addConverter);
	ThreeTenBackPortConverters.getConvertersToRegister()
			.forEach(conversionService::addConverter);

	this.conversionService = conversionService;
}