Android Kaki

Build beautiful, usable products using required Components for Android.

Unit Take a look at Failed on JDK17 — What is the Drawback? | by Nav Singh 🇨🇦 | April 2023

Lately, Flamingo Android Studio hit the steady channel. So I up to date the IDE and all labored as anticipated.

Flamingo Android Studio comes with default JDK set to JDK17

  • All labored as anticipated till I ran unit checks for our challenge

Assist our app English And French. So we now have unit checks for the foreign money format to ensure it really works as anticipated for each languages.

Assessments for the French foreign money format began to fail and we marvel why it began to fall JDK17

From the failed checks we discovered that there’s a downside with quantity separator🤯.

Give Frenchthe quantity separator To be change to 1 slim break house (NNBSP) U+202F

It should not be modified in JDK and it do not simply begin with JDK17

Earlier than JDK17We’re utilizing JDK11. Till JDK12 no downside with present quantity separator (NBSP)

on this bugsI see that it was launched by the change in Unicode Widespread Language Knowledge Archive(CLDR) that’s upstream supply of JDK

  • If you’re utilizing a hard-coded quantity separator
// <= JDK12
personal const val NBSP = "u00A0"

Later change it is a new one quantity separator

// Java 13 to 17
personal const val NNBSP = "u202F"

To ensure your checks are okay unbiased of JDKuse the next technique

 val separator = DecimalFormatSymbols.getInstance(Locale.FRENCH).groupingSeparator
* @creator Nav Singh
class FrenchNumberSeparatorTest {

@Take a look at
enjoyable `when Locale is French then examine quantity is correctly formatted`() {
val formattedNumber = formatNumberToFrenchLocale(1000)
Assert.assertEquals("1${separator}000", formattedNumber)

@Take a look at
enjoyable `when quantity is formatted for French locale then examine the quantity separator is legitimate`() {
val formatted = formatNumberToFrenchLocale(1000)
// Exhausting-coded separator - works solely upto JDK12
// Assert.assertEquals(NBSP, formatted.substring(1, 2))
Assert.assertEquals(separator, formatted.substring(1, 2))

personal enjoyable formatNumberToFrenchLocale(quantity: Int): String {
val format = NumberFormat.getInstance(Locale.FRANCE)
return format.format(quantity.toLong())

companion object {

// Quantity separator in Java 8, 11 & 12.
personal const val NBSP = "u00A0"

// Quantity separator in Java 13 to 17.
personal const val NNBSP = "u202F"

// Get quantity separator and use it
val separator = DecimalFormatSymbols.getInstance(Locale.FRENCH).groupingSeparator.toString()


John Wick: Chapter 4 (FREE) FULLMOVIE The Super Mario Bros Movie avatar 2 Where To Watch Creed 3 Free At Home Knock at the Cabin (2023) FullMovie Where To Watch Ant-Man 3 and the Wasp: Quantumania Cocaine Bear 2023 (FullMovie) Scream 6 Full Movie
Updated: April 18, 2023 — 8:11 am

Leave a Reply

Your email address will not be published. Required fields are marked * © 2023 Android kaki