format = createFormat(type); if (format != null) { if (formats == null) {
format = createFormat(valueType); if (format == null) { Class<?> type = valueType; format = createFormat(type); if (format != null) { formats.put(type, format);
/** * Creates a new format to use for parsing and formatting values of the given type. * This method is invoked the first time that a format is needed for the given type. * The {@code valueType} can be any types declared in the * {@linkplain CompoundFormat#createFormat(Class) parent class}. * * @param valueType the base type of values to parse or format. * @return the format to use for parsing of formatting values of the given type, or {@code null} if none. */ @Override protected Format createFormat(final Class<?> valueType) { if (valueType == Number.class) { return symbols.createNumberFormat(); } if (valueType == Date.class) { return new StandardDateFormat(symbols.getLocale(), getTimeZone()); } final Format format = super.createFormat(valueType); if (format instanceof UnitFormat) { ((UnitFormat) format).setStyle(UnitFormat.Style.NAME); } return format; }
/** * Creates a new format to use for parsing and formatting values of the given type. * This method is invoked the first time that a format is needed for the given type. * The {@code valueType} can be any types declared in the * {@linkplain CompoundFormat#createFormat(Class) parent class}. * * @param valueType the base type of values to parse or format. * @return the format to use for parsing of formatting values of the given type, or {@code null} if none. */ @Override protected Format createFormat(final Class<?> valueType) { if (valueType == Number.class) { return symbols.createNumberFormat(); } if (valueType == Date.class) { return new StandardDateFormat(symbols.getLocale(), getTimeZone()); } final Format format = super.createFormat(valueType); if (format instanceof UnitFormat) { ((UnitFormat) format).setStyle(UnitFormat.Style.NAME); } return format; }