<p>Apparently the app shows the amount as Satoshi (the smallest unit) instead of BTC. For internal calculations that's ok because it avoids rounding errors, but for input and output you should scale by an appropriate factor (10^8 for BTC, or 10^5 for mBTC).</p>

CC BY-SA 3.0
2017-05-31T04:33:19.370Z
2017-05-31T04:33:19.370Z
Hans-Martin Mosner
<p>Yes, and in bitcoinj there are actually two classes for formatting Coin values for humans: MonetaryFormat and BtcFormat. I strongly suggest using one of the two.</p>

<p>Here's an example:</p>

<pre><code>Wallet wallet = &lt;initialize wallet here&gt;
String friendlyFormat = BtcFormat.getInstance().format(wallet.getBalance());
</code></pre>

CC BY-SA 3.0
2017-05-31T07:51:40.467Z
How to convert Satoshies to BTC in Java?
Arefe
CC BY-SA 3.0
2017-06-01T04:21:12.720Z
What does the `wallet.getBalance()` returns? I have tried with several ways and none actually works for me. The method I use to get the Satoshi Coin is 

   `public Coin getBalance() {
        return balance;
    }`

How can I get the correct value in BTC? I have also tried with `balance.leftShift(8)`
Arefe
CC BY-SA 3.0
2017-05-31T07:30:16.890Z
2017-05-31T20:43:16.143Z
2017-05-31T20:43:16.143Z
Andreas
<p>I work with <code>Java/Maven/JSP</code> app with <code>BitcoinJ</code> and I have transfer about 0.0048 BTC from a testnet faucet. However, after receiving, I see that my account has balance of <code>480000.00  BTC</code>. </p>

<p><a href="https://i.sstatic.net/2h5aA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2h5aA.png" alt="enter image description here"></a></p>

<p>This is the method I have used to get the Satoshi <code>Coin</code>. </p>

<pre><code>public Coin getBalance() {
        return balance;
    }
</code></pre>

<p>I have checked the code and at least my backend part looks normal to me. How to approach to this problem?</p>

<blockchain><bitcoinj><java><divisibility>
The BTC shows 10^8 times more than what is received in the account
Arefe
# The BTC shows 10^8 times more than what is received in the account

(Asked by: username_0 on 2017-05-31)

I work with `Java/Maven/JSP` app with `BitcoinJ` and I have transfer about 0.0048 BTC from a testnet faucet. However, after receiving, I see that my account has balance of `480000.00 BTC`.

[![enter image description here](https://i.sstatic.net/2h5aA.png)](https://i.sstatic.net/2h5aA.png)

This is the method I have used to get the Satoshi `Coin`.

```
public Coin getBalance() {
        return balance;
    }

```

I have checked the code and at least my backend part looks normal to me. How to approach to this problem?

**Tags:** blockchain, bitcoinj, java, divisibility


---

## 2 answers

### Answer by username_1 on 2017-05-31. Score: 3 | Accepted answer

Apparently the app shows the amount as Satoshi (the smallest unit) instead of BTC. For internal calculations that's ok because it avoids rounding errors, but for input and output you should scale by an appropriate factor (10^8 for BTC, or 10^5 for mBTC).


---

### Answer by username_2 on 2017-05-31. Score: 2

Yes, and in bitcoinj there are actually two classes for formatting Coin values for humans: MonetaryFormat and BtcFormat. I strongly suggest using one of the two.

Here's an example:

```
Wallet wallet = <initialize wallet here>
String friendlyFormat = BtcFormat.getInstance().format(wallet.getBalance());

```

> **Comments:**
> **username_0**: How to convert Satoshies to BTC in Java?  
> **username_0**: What does the `wallet.getBalance()` returns? I have tried with several ways and none actually works for me. The method I use to get the Satoshi Coin is      `public Coin getBalance() {         return balance;     }`  How can I get the correct value in BTC? I have also tried with `balance.leftShift(8)`  

---

