Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Introduction to Functional Programming Functional Programming Fundamentals Compose Price Conversion Functions

Formats won't match from other environments

com.teamtreehouse.challenges.homes.MainTest > argentinaRecordsAreFormattedAndConverted FAILED

Expected: "First is $1.00 (USD) which is $15,48 (Argentine Peso)" Actual: "First is $1.00 (USD) which is $�15,48 (Argentine Peso)"

Tonnie Fanadez
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 Points

@Ahmed Jadou Thanks for bringing this up, I spent hours on this challenge and didn't figure it. I am following this discussion closely.

1 Answer

I am sure your soluation is correct. Please add this method as workarond created by Steven Branson

static String fakeFormatter(BigDecimal price) {
      String pString = String.valueOf(price);
      return String.format("$%s,%s",
      pString.substring(0, pString.indexOf('.')),
      pString.substring(pString.indexOf('.') + 1, pString.indexOf('.') + 3));

then edit this line below

String.format("%s (%s)", fakeFormatter(price), currentCurrency.getDisplayName());

Keep learning ..