|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -46,10 +46,10 @@ import org.springframework.util.StringUtils;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class WebConversionService extends DefaultFormattingConversionService {
|
|
|
|
public class WebConversionService extends DefaultFormattingConversionService {
|
|
|
|
|
|
|
|
|
|
|
|
private static final boolean jsr354Present = ClassUtils.isPresent(
|
|
|
|
private static final boolean JSR_354_PRESENT = ClassUtils.isPresent(
|
|
|
|
"javax.money.MonetaryAmount", WebConversionService.class.getClassLoader());
|
|
|
|
"javax.money.MonetaryAmount", WebConversionService.class.getClassLoader());
|
|
|
|
|
|
|
|
|
|
|
|
private static final boolean jodaTimePresent = ClassUtils.isPresent(
|
|
|
|
private static final boolean JODA_TIME_PRESENT = ClassUtils.isPresent(
|
|
|
|
"org.joda.time.LocalDate", WebConversionService.class.getClassLoader());
|
|
|
|
"org.joda.time.LocalDate", WebConversionService.class.getClassLoader());
|
|
|
|
|
|
|
|
|
|
|
|
private final String dateFormat;
|
|
|
|
private final String dateFormat;
|
|
|
@ -72,14 +72,14 @@ public class WebConversionService extends DefaultFormattingConversionService {
|
|
|
|
|
|
|
|
|
|
|
|
private void addFormatters() {
|
|
|
|
private void addFormatters() {
|
|
|
|
addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
|
|
|
|
addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
|
|
|
|
if (jsr354Present) {
|
|
|
|
if (JSR_354_PRESENT) {
|
|
|
|
addFormatter(new CurrencyUnitFormatter());
|
|
|
|
addFormatter(new CurrencyUnitFormatter());
|
|
|
|
addFormatter(new MonetaryAmountFormatter());
|
|
|
|
addFormatter(new MonetaryAmountFormatter());
|
|
|
|
addFormatterForFieldAnnotation(
|
|
|
|
addFormatterForFieldAnnotation(
|
|
|
|
new Jsr354NumberFormatAnnotationFormatterFactory());
|
|
|
|
new Jsr354NumberFormatAnnotationFormatterFactory());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
registerJsr310();
|
|
|
|
registerJsr310();
|
|
|
|
if (jodaTimePresent) {
|
|
|
|
if (JODA_TIME_PRESENT) {
|
|
|
|
registerJodaTime();
|
|
|
|
registerJodaTime();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
registerJavaDate();
|
|
|
|
registerJavaDate();
|
|
|
|