我在Grails中使用和CustomDateEditor麻烦2.1.0Grails的2.1和和CustomDateEditor似乎并没有工作
我想要实现:
Date类现在呈现为08/10/2013 00:00:00 CEST但我想的格式更改为2013年8月10日(DD/MM/YYYY格式)
什么我迄今所做的:
resource.groovy
beans = {
customPropertyEditorRegistrar(myutil.CustomPropertyEditorRegistrar)
}
myutil.CustomPropertyEditorRegistrar
package myutil
import org.springframework.beans.PropertyEditorRegistrar
import org.springframework.beans.PropertyEditorRegistry
import org.springframework.beans.propertyeditors.CustomDateEditor
import java.text.SimpleDateFormat
public class CustomPropertyEditorRegistrar implements PropertyEditorRegistrar {
public void registerCustomEditors(PropertyEditorRegistry registry) {
registry.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat('dd/MM/yyyy'), true)) //this doesn't work
registry.registerCustomEditor(java.math.BigDecimal.class, new CurrencyPropertyEditor()) //this work so at least the registerCustomEditors method is invoked
}
}
正如你可以在我的代码中看到有是工作得很好,所以我很困惑这里CurrencyPropertyEditor ..这是怎么回事?
我搜索了所有的东西,它似乎并不是我的代码是错误的,但仍然无法正常工作。
非常感谢您提供任何提示。
嗯..不知道,为什么2 downvote ..是这个问题那么糟吗? –