Formatting in decimalformat

Source: Internet
Author: User

I. Preface

You can see new things on your own every day and learn things on your own, but you feel that you always want to eat a fat man. Every day, I see a knowledge point added to my favorites, but I don't have time to read it. I don't know what I want to thank. I am speechless. I have summarized all the knowledge I have learned recently. I have a summary of one aspect, but I still have no time and don't know what I want to thank. Annoying! It is because my heart is too big, but my ability is indeed unable to keep up. Recently I want to review Java and learn Linux and python. Now I want to ask myself, do you have so much time to learn these things? The answer is no. Do your best.

Ii. Problem

Today, I started my company's pocket money module for me. When I made a report, I encountered a lower-case conversion in upper case. Now I want to know how to use the decimalformat class.

Let's look at the differences in the code!

 

The Code is as follows:

Package javatest; import Java. text. decimalformat; public class demacialformatdemo {public static void main (string ARGs []) {decimalformat F1, F2; F1 = new decimalformat ("0.000"); F2 = new decimalformat ("#. 000 "); system. out. println ("with 0" + f1.format (0.20); system. out. println ("with #" + f2.format (0.20); F1 = new decimalformat ("0.00"); F2 = new decimalformat ("0. # "); system. out. println ("decimal point 00:" + f1.format (0.2); system. out. println ("decimal point ##:" + f2.format (0.2); F1 = new decimalformat ("0.00"); F2 = new decimalformat ("##. 00 "); system. out. println ("00 INTEGER:" + f1.format (22); system. out. println ("# INTEGER:" + f2.format (22 ));}}

 

Formatting in decimalformat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.