Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize the DecimalFormatSeparator in PeriodFormatter appendSecondsWithMillis #414

Open
dektar opened this issue Feb 15, 2017 · 1 comment
Labels

Comments

@dektar
Copy link

dektar commented Feb 15, 2017

Key information

  • Joda-Time version: 2.9.4

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:

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.

@jodastephen
Copy link
Member

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants