Ooh … Begitu! I see, I see …

Icon

Setelah kelayapan di internet, cari-cari info dari sana-sini dan bongkar pasang tips (terutama programming), akhirnya baru sadar … ternyata begitu caranya … [all about tricks and tips I have found during my work as programmer.]

cast Double to String in java

Double to String casting …
if you want to display its String in number format (like this ###,###,##0.00) do not use these lines …

    
    Double sk = 12300000000.35;
    System.out.println(sk.toString());
    System.out.println(String.valueOf(sk));

they would result like these ones:

1.230000000035E10
1.230000000035E10

use this one instead.

    
    Double sk = 12300000000.35;
    NumberFormat nm = NumberFormat.getNumberInstance();

    System.out.println(nm.format(sk));

the latter result would be this:
12.300.000.000,35

Advertisements

Filed under: Java programming, , , , , , ,

One Response

  1. Kaka says:

    wow, excellently explained. This was Exactly what I was looking for. Thank you very much. Please keep it up. You have been very helpful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives

%d bloggers like this: