Spring Framework FormattingConversionService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework FormattingConversionService class.

This code example shows how to use the following methods:addConverter
		String attrName = "person";
		this.redirectAttributes.addAttribute(attrName, new TestBean("Fred"));
 
		assertEquals("ConversionService should have invoked toString()", "Fred", this.redirectAttributes.get(attrName));
 
		this.conversionService.addConverter(new TestBeanConverter());
		this.redirectAttributes.addAttribute(attrName, new TestBean("Fred"));
 
		assertEquals("Type converter should have been used", "[Fred]", this.redirectAttributes.get(attrName));
	} 
 
	@Test
	public void addAttributeToString() { 
		String attrName = "person";
		RedirectAttributesModelMap model = new RedirectAttributesModelMap();
		model.addAttribute(attrName, new TestBean("Fred"));
 
		assertEquals("toString() should have been used", "Fred", model.get(attrName));
	} 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:convert
This code example shows how to use the following methods:addConverter, addConverterFactory
		return this;
	} 
 
	public TupleBuilder setNumberFormatFromLocale(Locale locale) {
		Assert.notNull(locale);
		formattingConversionService.addConverterFactory(new LocaleAwareStringToNumberConverterFactory(NumberFormat
				.getInstance(locale)));
		return this;
	} 
 
	public TupleBuilder setDateFormat(DateFormat dateFormat) {
		Assert.notNull(dateFormat);
		formattingConversionService.addConverter(new StringToDateConverter(dateFormat));
		return this;
	} 
 
	void addEntry(String k1, Object v1) {
		names.add(k1);
		values.add(v1);
	} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java