Skip to content

Commit

Permalink
Specifically detect Joda-Time 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller authored and engimatic committed Sep 29, 2020
1 parent 92ef388 commit 0922569
Showing 1 changed file with 11 additions and 7 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,19 +39,23 @@
* {@link DefaultConversionService#addDefaultConverters addDefaultConverters} method.
*
* <p>Automatically registers formatters for JSR-354 Money & Currency, JSR-310 Date-Time
* and/or Joda-Time, depending on the presence of the corresponding API on the classpath.
* and/or Joda-Time 2.x, depending on the presence of the corresponding API on the classpath.
*
* @author Chris Beams
* @author Juergen Hoeller
* @since 3.1
*/
public class DefaultFormattingConversionService extends FormattingConversionService {

private static final boolean jsr354Present = ClassUtils.isPresent(
"javax.money.MonetaryAmount", DefaultFormattingConversionService.class.getClassLoader());
private static final boolean jsr354Present;

private static final boolean jodaTimePresent = ClassUtils.isPresent(
"org.joda.time.LocalDate", DefaultFormattingConversionService.class.getClassLoader());
private static final boolean jodaTimePresent;

static {
ClassLoader classLoader = DefaultFormattingConversionService.class.getClassLoader();
jsr354Present = ClassUtils.isPresent("javax.money.MonetaryAmount", classLoader);
jodaTimePresent = ClassUtils.isPresent("org.joda.time.YearMonth", classLoader);
}


/**
Expand All @@ -78,7 +82,7 @@ public DefaultFormattingConversionService(boolean registerDefaultFormatters) {
* Create a new {@code DefaultFormattingConversionService} with the set of
* {@linkplain DefaultConversionService#addDefaultConverters default converters} and,
* based on the value of {@code registerDefaultFormatters}, the set of
* {@linkplain #addDefaultFormatters default formatters}
* {@linkplain #addDefaultFormatters default formatters}.
* @param embeddedValueResolver delegated to {@link #setEmbeddedValueResolver(StringValueResolver)}
* prior to calling {@link #addDefaultFormatters}.
* @param registerDefaultFormatters whether to register default formatters
Expand Down

0 comments on commit 0922569

Please sign in to comment.