Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,793 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 ..