Format package java.text from double type data to data

Source: Internet
Author: User

Requirement: Double type data interception operation retains two decimal places

Solution:

1 Java.text.DecimalFormat df =new java.text.DecimalFormat ("#.00");

2 Df.format (the number you want to format);

Can also be written as a sentence:

1 new Java.text.DecimalFormat ("#.00"). Format (the number you want to format);

Extension: Java.text Package: Provides classes and interfaces that work with text, dates, numbers, and messages in a way that is not related to natural language.

Java.text:

1st: Formatting dates, numbers and messages

2nd: Parsing, searching, and sorting strings

3rd: Iterate characters, words, statements and line breaks

The Group of class:
1st-group: The class of the iteration text
2nd-group: Classes for formatting and parsing
3rd-group: Class for collating strings

Class Structure:

Format base class----> DataFormat, NumberFormat, Messageformat three formats for scenarios----> under three categories under the sub-category, Eg:numberformat under: Choiceformat and De Cimalformat.

Format package java.text from double type data to data

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.