Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8266929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:20:22+00:00 2026-06-08T05:20:22+00:00

I am trying to parse and store currency amounts as BigDecimal values. I am

  • 0

I am trying to parse and store currency amounts as BigDecimal values. I am given the locale of the currency in question, and in most cases it works fine, but I’m getting unexpected results when the currency is the Costa Rican colón.

I am informed by my Costa Rican customers that a typical currency amount might look like 1.508.534,16 with the ,16 being the fractional part (two decimal places). However, when I call Currency.getDefaultFractionDigits() it returns 0 instead of 2 as the number of fractional digits. As a result, the values I’m calculating are being wrongly truncated.

Code looks like this:

// currencyLocale is "es_CR"
Currency currency = Currency.getInstance(currencyLocale);
int scale = currency.getDefaultFractionDigits();
// scale is 0 instead of 2

BigDecimal v = new BigDecimal("12.34")
                          .setScale(scale, BigDecimal.ROUND_HALF_DOWN);
// gives 12 instead of 12.34

Note that although the end-user-visible amounts are correctly formatted for the locale with the , as the decimal separator, the data source here is providing the values as standard 1234.56 decimal amounts.

What am I doing wrong?


UPDATE

After doing some more research, and reporting the issue to Google, I am now convinced this is an Android bug. Google’s response is that this works as intended, since the affected currencies can only be spent in whole-number multiples (smallest coin is 5 colón).

Google’s response ignores the fact that you can quite legitimately have fractional amounts in your bank account, though, as a result of wire transfers, interest calculations, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:20:26+00:00Added an answer on June 8, 2026 at 5:20 am

    Not really an answer, but this prints 2 (Java JDK, not Android):

    public static void main(String[] args) {
        Locale currencyLocale = new Locale("es","CR");
        Currency currency = Currency.getInstance(currencyLocale);
        System.out.println(currency.getDefaultFractionDigits());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to parse some XML but apparently this is too much for a lazy
I am trying to parse the following XML file in Java and to store
I'm trying to parse a web service response using SAXParser and get certain values,
Question abstract: how to parse text file into two hashes in Perl. One store
I'm trying to parse JSON string using Boost Spirit store JSON object into recursive
I am trying to parse a xml from some source and store the results
I am trying to parse the digits to store in a variable from a
I am trying to store some parsed feed contents values in Sqlite database table
I am trying to parse a moderately large xml file, store it in an
I am trying to parse a date from a textbox and store it in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.