English 中文(简体)
当地化月名称
原标题:SimpleDateFormat localized month names

I have searched throughout the site but I think I have a slightly different issue and could really do with some help before I either have heart failure or burn the computer.

我生动地提出每月名单(以2011年6月、2011年7月的形式),我显然希望这份名单具有地方敏感性:因此,我使用简单的日期格式反对如下:

//the actual locale name is dependent on UI selection
Locale localeObject=new Locale("pl"); 
// intended to return full month name - in local language.
DateFormat dtFormat = new SimpleDateFormat("MMMM yyyy",localeObject);
//this bit just sets up a calendar (used for other bits but here to illustrate the issue
String systemTimeZoneName = "GMT";
TimeZone systemTimeZone=TimeZone.getTimeZone(systemTimeZoneName);
Calendar mCal = new GregorianCalendar(systemTimeZone); //"gmt" time
mCal.getTime(); //current date and time

但是,如果我这样做的话:

String value=dtFormat.format(mCal.getTime()); 

this "should" return the localized version of the month name. In polish the word "September" is "Wrzesień" -- note the accent on the n. However all I get back is "Wrzesie?"

我做了什么错误?

由于大家——现在我接受,它是一个介绍问题——但我如何能够安全地“阅读”地通过 d子产生的结果——我在下文加上一些评论,在其它情况下这样做——我似乎可以不夸张地取得明显的结果。

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The answer was on BalusC s blog : http://balusc.blogspot.com/2009/05/unicode-how-to-get-characters-right.html#DevelopmentEnvironment

基本上,DTformat物体正在返回UTF-8,正被自动转变为系统缺省特性,而当时我把它看成一个扼杀装置。

因此,这部法典对我工作。

new String(dtFormat.format(mCal.getTime()).getBytes("UTF-8"),"ISO-8859-1");

非常感谢您的援助。

最佳回答

你的问题与<条码>无关。 页: 1

You haven t told us what you re doing with the string afterwards - how you re displaying it in the UI - but that s the problem. You can see that it s fetching a localized string; it s only the display of the accented character which is causing a problem. You would see exactly the same thing if you had a string constant in there containing the same accented character.

我建议,如果你带上网站,就检查你在座标上所用的所有编码,或检查你如果带上ole子或 Sw子,则重新显示插座。

如果你审查一下猪肉的扼杀,我相信你会看到它完全是正确的特性——这只是他们如何重新接触到问题使用者。

问题回答

在我的测试中,dtFormat.format(mCal.gettime() 回归

październik 2011

<代码>新 简明表格(0,0, localeObject).format(mCal.gettime()回报:

poniedziarovek, 3 październik 2011 14:26:53 EDT





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签