要解决PeriodFormat中的Joda Time错误? [英] Work-around for a Joda Time bug in PeriodFormat?
问题描述
这是我的代码,其中显示了一个Joda Time错误:
Here's my code which reveals a Joda Time bug:
import org.joda.time.Period;
import org.joda.time.format.PeriodFormat;
import org.joda.time.format.PeriodFormatter;
import java.util.Locale;
public class ScratchSpace {
public static void main(String[] args) {
Locale.setDefault(Locale.GERMAN);
final PeriodFormatter periodFormatter =
PeriodFormat.wordBased(Locale.ENGLISH);
final Period period = new Period(6, 5, 4, 3);
final String s = period.toString(periodFormatter);
// i'm expecting english to be outputted
System.out.println("s = " + s); // outputs german: 6 Stunden, 5 Minuten, 4 Sekunden und 3 Millisekunden
}
}
根据JavaDocs,我应该获取英文格式的句点.但是它使用的是当前的默认语言环境,在上面的示例中是德语.
According to the JavaDocs I should be getting the period formatted in English. But it is using the current default locale instead, which in the example above is German.
我正在Mac OS X 10.7上使用Joda Time 2.0,并且将计算机设置为澳大利亚英语"作为首选语言.
I'm using Joda Time 2.0, on Mac OS X 10.7, with the computer set to "Australian English" as the preferred language.
您可以提出任何简单的解决方法吗?
Any simple work-around you can suggest?
推荐答案
另一种解决方案是更新到最新的Joda Time来源...根据此错误报告,现已修复: http://sourceforge.net/tracker/?func = detail& aid = 3471414& group_id = 97367& atid = 617889
Another solution is to update to the latest Joda Time source...according to this bug report it is now fixed: http://sourceforge.net/tracker/?func=detail&aid=3471414&group_id=97367&atid=617889
这篇关于要解决PeriodFormat中的Joda Time错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!