Skip to main content

Custom Formatter

Learn Custom Formatter (Data Binding, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Fresher Notes Custom Formatter : your own class implementing Formatter<T> with two methods, parse(String, Locale) and print(T, Locale) . Use it when a value has a human text form that built-in formatters do not know, such as a phone number, a money amount with currency or a product code. Register it in WebMvcConfigurer.addFormatters ; after that the type binds automatically from text.

More lessons in Data Binding