Enter a date to a date field without dots


I am trying to enter date to datefield without using dots (‘.’).Normally ı can successfully enter a date to a datefield using keyboard with dots without any problem .However I am wondering it is possible to enter a datefield without using dots as below

11192013 → 11/19/2013

Is there a simple way to do this ?


As far as I know there’s no automatic way to do this. However, you can override the handleUnparsableDateString of DateField and parse the dotless input into a proper Date object yourself.

should work?

Surely. I assumed he wants to keep accepting dates with separator characters also, which I think is not possible with a single date format.

Thanks a lot for your responses.

I wanted the clarify the situation here.The thing that i am trying to do is not formatiing the dateField value.

I want to enter to the datefield without any delimiters ,After i entered the value i expect the field value automatically be formatted.

Before enter
After enter

Is this possible ?

Try this:

 DateField df = new DateField() {
            protected Date handleUnparsableDateString(String dateString)
                    throws ConversionException {
                DateFormat df = new SimpleDateFormat("MMddyyyy");
                try {
                    return df.parse(dateString);
                } catch (ParseException e) {
                    throw new ConversionException("Cannot parse: " + dateString);

Thanks a lot Teppo ,Johannes.

My problem is resolved by overriding handleUnparsableDateString metod.