You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Joda-Time does not use the localized decimal format separator for parsing and printing. Instead, the "." character is hard-coded in several places in PeriodFormatterBuilder.java.
Make a formatter with a Locale:
mPeriodFormatter = new PeriodFormatterBuilder()
.rejectSignedValues(true) // Applies to all fields
.printZeroAlways() // Applies to all fields
.appendHours()
.appendLiteral(hourMinuteDivider)
.minimumPrintedDigits(2) // Applies to minutes and seconds
.appendMinutes()
.appendLiteral(minuteSecondDivider)
.appendSecondsWithMillis()
.toFormatter()
.withLocale(mLocale);
The SecondsWithMillis field should respect the locale. Use Finnish or Turkish and you expect a "," separator, vs English, which expects a "." separator. In fact, both always uses the "." when printing.
The text was updated successfully, but these errors were encountered:
This is not an unreasonable enhancement request. However, now Java 8 is out, Joda-Time is essentially considered a finished project, and I have no personal plans to work on enhancments,
Key information
Problem description
Joda-Time does not use the localized decimal format separator for parsing and printing. Instead, the "." character is hard-coded in several places in PeriodFormatterBuilder.java.
Example:
joda-time/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java
Line 1471 in 43b1799
Instead, Joda-Time should use the localized DecimalFormatSeparator, which can be retrieved from DecimalFormatSymbols.getInstance(locale).getDecimalSeparator.
https://developer.android.com/reference/java/text/DecimalFormatSymbols.html#getDecimalSeparator()
http://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormatSymbols.html#getDecimalSeparator()
Test case
Make a formatter with a Locale:
mPeriodFormatter = new PeriodFormatterBuilder()
.rejectSignedValues(true) // Applies to all fields
.printZeroAlways() // Applies to all fields
.appendHours()
.appendLiteral(hourMinuteDivider)
.minimumPrintedDigits(2) // Applies to minutes and seconds
.appendMinutes()
.appendLiteral(minuteSecondDivider)
.appendSecondsWithMillis()
.toFormatter()
.withLocale(mLocale);
The SecondsWithMillis field should respect the locale. Use Finnish or Turkish and you expect a "," separator, vs English, which expects a "." separator. In fact, both always uses the "." when printing.
The text was updated successfully, but these errors were encountered: