문제

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