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