In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the java.text.DecimalFormat class decimal format example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Java.text.DecimalFormat class decimal format of the specific code for your reference, the specific content is as follows
Import java.text.DecimalFormat; class FormatDemo {public void format1 (String pattern,double value) {/ / declare a DecimalFormat object DecimalFormat df = new DecimalFormat (pattern); String str = df.format (value); System.out.println ("format using" + pattern + "style:" + value + "to get:" + str) }} public class Test {public static void main (String args []) {FormatDemo fd = new FormatDemo (); fd.format1 ("#, #. #", 111222.34567); / / not enough to round up 0 fd.format1 ("000000.000", 11222.34567); fd.format1 ("#, #. # ¥", 111222.34567) Fd.format1 ("000000.000 ¥", 11222.34567); / / how many per cent fd.format1 ("# #. #%", 0.345678); / / how many per cent fd.format1 ("00.percent percentage percentage", 0.0345678); / / how much fd.format1 ("#. # / u2030", 0.345678) / / exponential form DecimalFormat df1 = new DecimalFormat (); / / use this thing applypattern df1.applyPattern ("0"); System.out.println (df1.format (111222.34567));}}
The result of running the program:
Use #: 111222.34567 get: 111222.346 use 000000.000 style format: 11222.34567 get: 011222.346 use # # #. # ¥format: 111222.34567 get: 111222.346 ¥using 000000.000 ¥style format: 11222.34567 get: 011222.346 ¥using # #. #% style format: 0.345678 get: 34.568% format: 0.0345678 get: 03.457% use # ‰ style format: 0.345678 get: 345.678 ‰ 111200
DecimalFormat format template
Thank you for reading this article carefully. I hope the article "sample Analysis of java.text.DecimalFormat Decimal format" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.