且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

日期字符串显示问号

更新时间:2023-11-07 13:56:22

这只是Eclipse控制台未处理印度编号系统.当我在外壳中的Linux上运行相同的代码时,我得到:

It's just the Eclipse console not handling the Indian numbering system. When I run that same code on Linux in a shell, I get:

२०१६-०३-१६

如Alexandar所述,将Eclipse控制台编码更改为包含所有必需字符的编码可以解决此问题-但我不清楚yyyy-MM-dd的格式是否适合该语言环境.通常,该格式用于可机读的日期,为此,您应指定Locale.ROOTLocale.US作为用于设置格式的语言环境.

As noted by Alexandar, changing the Eclipse console encoding to one which includes all the required characters fixes this - but it's unclear to me whether a format of yyyy-MM-dd is appropriate in that locale anyway. Usually that format is used for machine-readable dates, for which you should specify Locale.ROOT or Locale.US as the locale to use for formatting.