Is it possible to configure the date pattern in use when using springs @DateTimeFormat(style = "M-")? - Stack

I am working on a spring web application with support for multiple languages for the UI. Example form-m

I am working on a spring web application with support for multiple languages for the UI. Example form-model:

class PersonModel {
   @DateTimeFormat(style = "M-")
   private java.util.Date birthdate;
}

With this model and a birthdate January 13th, 2000 it renders to a form-input like:

"13.01.2000" (de_DE)

"13 Jan 2000" (en_GB)

German format is fine but I want the en_GB format to be like "13/01/2000". How can I customize it?

Using @DateTimeFormat(style = "S-") is sadly not an option because it renders the german year with just 2 digits.

"13.01.00" (de_DE)

"13/01/2000" (en_GB)

It seems it uses DateFormat.getDateInstance(DateFormat.MEDIUM, locale); under the hood. Spring Boot version is 2.7.18 but upgrade to version 3 is planned.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744714692a4589546.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信