strai1.mail
(Raymutsen Stephen)
#1
Hello,
I am using version 7.1 and I need to implement the formatting of phone numbers of a column in a table for a good presentation.
import com.haulmont.cuba.gui.components.Formatter;
public class PhoneFormatter implements Formatter<String> {
@Override
public String format(String value) {
if (value != null && value.length() == 9)
return value.substring(0, 3) + "-" + value.substring(3, 6) + "-" + value.substring(6);
return value;
}
}
Can you give me an example with Function<T, String>
I do not understand how to implement it.
thank you so much
import java.util.function.Function;
public class PhoneFormatter implements Function<String, String> {
@Override
public String format(String value) {
if (value != null && value.length() == 9)
return value.substring(0, 3) + "-" + value.substring(3, 6) + "-" + value.substring(6);
return value;
}
}
gorelov
(Gleb Gorelov)
#3
Hi,
Below the example of implementing Function
:
import java.util.function.Function;
...
public static class UppercaseFormatter implements Function<String, String> {
@Override
public String apply(String value) {
return value.toUpperCase();
}
}
Gleb