plugins.DateUtils.defaultTimeFormat

We are trying to override the date format using the regional OS settings do we used the above plugin property. It returned MMM d, yyyy. We are using mask.

When I use it, we cannot enter characters in MMM. And we get an exception.

2011-10-25 10:21:52,454 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - Throwable
java.text.ParseException: Format.parseObject(String) failed
	at java.text.Format.parseObject(Unknown Source)
	at javax.swing.text.InternationalFormatter.stringToValue(Unknown Source)
	at javax.swing.text.InternationalFormatter.stringToValue(Unknown Source)
	at com.servoy.j2db.smart.dataui.DataField$NullDateFormatter.stringToValue(DataField.java:453)
	at com.servoy.j2db.smart.dataui.DataField$NullDateFormatter$FixedMaskDateFormatter.stringToValue(DataField.java:550)
	at javax.swing.JFormattedTextField.commitEdit(Unknown Source)
	at com.servoy.j2db.smart.dataui.DataField.commitEdit(DataField.java:1840)
	at com.servoy.j2db.smart.dataui.DataField$1.fireLeaveCommands(DataField.java:695)
	at com.servoy.j2db.smart.dataui.EventExecutor.focusLost(EventExecutor.java:257)
	at java.awt.AWTEventMulticaster.focusLost(Unknown Source)
	at java.awt.AWTEventMulticaster.focusLost(Unknown Source)
	at java.awt.Component.processFocusEvent(Unknown Source)
	at javax.swing.JFormattedTextField.processFocusEvent(Unknown Source)
	at com.servoy.j2db.smart.dataui.DataField.processFocusEvent(DataField.java:1152)

I also tried to directry put the MMM d, yyyy format in design time and bypass the override but the same exception occurs. Moreso, when we click on the next field, the cursor is going back and forth the next field and the invalid date field.

When I tried to remove the mask it worked but would need to follow the format.

Also tried this one from a forum post (viewtopic.php?f=2&t=16247&p=87648&hilit=date+mask#p87648) hoping a workaround but the date is off.

format: MMM d, yyyy|MMMdyyyy
entered: Jan112011
onlostfocus: Jan 1, 12011

Hope this helps.

anybody had the same problem or any idea how to fix this?

you have only 1 input for the day
try this:

format: MMM d, yyyy|MMMddyyyy

now the parsre expects 2 chars before the year, else it only expects 1 and the next is the first of the year.

jcompagner:
you have only 1 input for the day
try this:

format: MMM d, yyyy|MMMddyyyy

now the parsre expects 2 chars before the year, else it only expects 1 and the next is the first of the year.

Thanks Johan!

Is this a servoy or a java bug?
Here is our setup: at design time we have MM/dd/yyyy|mask and at runtime we get the and replace the element.format (MM/dd/yyyy), with plugins.DateUtils.defaultTimeFormat (which returned MMM d, yyyy), of the elements which has a string “|mask” in its format. Why does this type of format not working?

Thanks for the help. :)

how is it not working?
it is working fine, why are you replacing stuff with |mask in it with something else??

This behavior is not a bug in java or servoy, its just how the parser works.

jcompagner:
how is it not working?
it is working fine, why are you replacing stuff with |mask in it with something else??

This behavior is not a bug in java or servoy, its just how the parser works.

we want to use mask and use the OS settings date format.
so what we did at design we placed a display format(e.g. dd/MM/yyyy) and tick “use as mask”. And during form onload, we replace the date format with the plugins.DateUtils.defaultDateFormat

function onLoad(event) {
	
	setDateFormatToDateFields(event);
}
function setDateFormatToDateFields(event) {
  var formName = controller.getName();
  var fieldArray = formObject.elements;
  for (var ctr = 0; ctr < fieldArray.length; ctr++) {
    var fieldObject = fieldArray[ctr];
    if(fieldObject.format.indexOf("|mask") > -1)  { 
      dateFormat = plugins.DateUtils.defaultDateFormat+"|mask";
      fieldObject.setFormat(dateFormat);
    }
  }
}

The field would not accept characters.
We are using postgresql
the column definition is: birthday timestamp without time zone