Scala String Format

Little break from the heavy stuff !

Let's see an example on how someJavafeatures have been integrated in Scala. Specially about String formatting at the moment.

This SKB is about formatting numbers.

In the first example, we are seeing how to add leading zeros in front of a number. That can be useful when building some UI or dashboard so the alignment is fix no matter how big the number is. Pretty useful and easy to use !

Then formattingDouble, how to truncate the decimals as well as adding leading zeros. Play with it to get a good intuition about it.

And finally, getting closer toJavawithLocalewhich allow you to display a number the right way based on the location.Localecan also be used to format dates and currencies ! Feel free to search for more information online and try to implement the code in here.

Reveal more information and clues
Load Exercise