I have a bean with a date property called birthday:

<property name="birthday" value="06/12/1980"/>

Can I specify a date format for my bean, in order to get 6th December or 12th June or is the default one always used?

有帮助吗?

解决方案

There are options:

  • Inject the date and format in your bean to return the desired string representation.
  • Use the Formatter SPI and configure an instance of DateFormatter given to you out of the box. Here is the Javadoc.
  • Implement and register your own instance of Formatter and then pass it to @Formatted annotation. Or use other annotations for more special cases. This is described here.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top