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
}
}
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.
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?