Example usage for javax.swing.text DateFormatter DateFormatter

List of usage examples for javax.swing.text DateFormatter DateFormatter

Introduction

In this page you can find the example usage for javax.swing.text DateFormatter DateFormatter.

Prototype

public DateFormatter() 

Source Link

Document

This is shorthand for new DateFormatter(DateFormat.getDateInstance()).

Usage

From source file:org.springframework.richclient.form.FormatterFactory.java

public AbstractFormatter getFormatter(JFormattedTextField source) {
    Object value = source.getValue();
    DefaultFormatter formatter;/*from   www. j a v a 2s  . com*/
    if (value instanceof Date) {
        formatter = new DateFormatter();
    } else if (value instanceof Number) {
        formatter = new NumberFormatter();
    } else {
        formatter = new DefaultFormatter();
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Factory returning new formatter " + formatter + " for text field " + source);
    }
    valueCommitPolicy.configure(source, formatter);
    if (valueClass != null) {
        formatter.setValueClass(valueClass);
    } else if (value != null) {
        formatter.setValueClass(value.getClass());
    }
    return formatter;
}